diff --git "a/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Category_AlgebraCat_Basic.jsonl" "b/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Category_AlgebraCat_Basic.jsonl" new file mode 100644--- /dev/null +++ "b/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Category_AlgebraCat_Basic.jsonl" @@ -0,0 +1,40 @@ +{"state":"R : Type u\ninst✝ : CommRing R\nX✝ Y✝ : AlgebraCat R\na₁✝ a₂✝ : X✝ ⟶ Y✝\nh :\n (CategoryTheory.Functor.mk { obj := fun R_1 => ↑R_1, map := fun {X Y} f => f.toFun }).map a₁✝ =\n (CategoryTheory.Functor.mk { obj := fun R_1 => ↑R_1, map := fun {X Y} f => f.toFun }).map a₂✝\n⊢ ∀ (x : ↑X✝), a₁✝ x = a₂✝ x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by ","nextTactic":"intros x","declUpToTactic":"instance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.63_0.H48YBh5wPSCwfA0","decl":"instance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget "} +{"state":"R : Type u\ninst✝ : CommRing R\nX✝ Y✝ : AlgebraCat R\na₁✝ a₂✝ : X✝ ⟶ Y✝\nh :\n (CategoryTheory.Functor.mk { obj := fun R_1 => ↑R_1, map := fun {X Y} f => f.toFun }).map a₁✝ =\n (CategoryTheory.Functor.mk { obj := fun R_1 => ↑R_1, map := fun {X Y} f => f.toFun }).map a₂✝\nx : ↑X✝\n⊢ a₁✝ x = a₂✝ x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; ","nextTactic":"dsimp at h","declUpToTactic":"instance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.63_0.H48YBh5wPSCwfA0","decl":"instance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget "} +{"state":"R : Type u\ninst✝ : CommRing R\nX✝ Y✝ : AlgebraCat R\na₁✝ a₂✝ : X✝ ⟶ Y✝\nh : ⇑a₁✝ = ⇑a₂✝\nx : ↑X✝\n⊢ a₁✝ x = a₂✝ x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; ","nextTactic":"rw [h]","declUpToTactic":"instance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.63_0.H48YBh5wPSCwfA0","decl":"instance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget "} +{"state":"R : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\n⊢ ∀ (X : Type u),\n { obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map\n (𝟙 X) =\n 𝟙\n ({ obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.obj\n X)","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by ","nextTactic":"intro X","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"R : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX : Type u\n⊢ { obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map (𝟙 X) =\n 𝟙 ({ obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.obj X)","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; ","nextTactic":"apply FreeAlgebra.hom_ext","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"case w\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX : Type u\n⊢ ⇑({ obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map\n (𝟙 X)) ∘\n FreeAlgebra.ι R =\n ⇑(𝟙\n ({ obj := fun S => mk (FreeAlgebra R S),\n map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.obj\n X)) ∘\n FreeAlgebra.ι R","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; ","nextTactic":"simp only [FreeAlgebra.ι_comp_lift]","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"case w\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX : Type u\n⊢ FreeAlgebra.ι R ∘ 𝟙 X = ⇑(𝟙 (mk (FreeAlgebra R X))) ∘ FreeAlgebra.ι R","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ","nextTactic":"rfl","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"R : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\n⊢ ∀ {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z),\n { obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map\n (f ≫ g) =\n { obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map f ≫\n { obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map g","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n ","nextTactic":"intros","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"R : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ Y✝ Z✝ : Type u\nf✝ : X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Z✝\n⊢ { obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map\n (f✝ ≫ g✝) =\n { obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map f✝ ≫\n { obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map g✝","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; ","nextTactic":"apply FreeAlgebra.hom_ext","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"case w\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ Y✝ Z✝ : Type u\nf✝ : X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Z✝\n⊢ ⇑({ obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map\n (f✝ ≫ g✝)) ∘\n FreeAlgebra.ι R =\n ⇑({ obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map\n f✝ ≫\n { obj := fun S => mk (FreeAlgebra R S), map := fun {X Y} f => (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f) }.map\n g✝) ∘\n FreeAlgebra.ι R","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; ","nextTactic":"simp only [FreeAlgebra.ι_comp_lift]","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"case w\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ Y✝ Z✝ : Type u\nf✝ : X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Z✝\n⊢ FreeAlgebra.ι R ∘ (f✝ ≫ g✝) =\n ⇑((FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f✝) ≫ (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ g✝)) ∘ FreeAlgebra.ι R","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ","nextTactic":"ext1","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"case w.h\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ Y✝ Z✝ : Type u\nf✝ : X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Z✝\nx✝ : X✝\n⊢ (FreeAlgebra.ι R ∘ (f✝ ≫ g✝)) x✝ =\n (⇑((FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f✝) ≫ (FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ g✝)) ∘ FreeAlgebra.ι R) x✝","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n ","nextTactic":"erw [CategoryTheory.coe_comp]","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"case w.h\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ Y✝ Z✝ : Type u\nf✝ : X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Z✝\nx✝ : X✝\n⊢ (FreeAlgebra.ι R ∘ (f✝ ≫ g✝)) x✝ =\n ((⇑((FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ g✝)) ∘ ⇑((FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f✝))) ∘\n FreeAlgebra.ι R)\n x✝","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n ","nextTactic":"simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"case w.h\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ Y✝ Z✝ : Type u\nf✝ : X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Z✝\nx✝ : X✝\n⊢ FreeAlgebra.ι R (g✝ (f✝ x✝)) =\n ((FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ g✝)) (((FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f✝)) (FreeAlgebra.ι R x✝))","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n ","nextTactic":"erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"case w.h\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ Y✝ Z✝ : Type u\nf✝ : X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Z✝\nx✝ : X✝\n⊢ FreeAlgebra.ι R (g✝ (f✝ x✝)) = (FreeAlgebra.ι R ∘ g✝) (f✝ x✝)","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n ","nextTactic":"rfl","declUpToTactic":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.147_0.H48YBh5wPSCwfA0","decl":"/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S "} +{"state":"R : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\n⊢ ∀ {X' X : Type u} {Y : AlgebraCat R} (f : X' ⟶ X) (g : X ⟶ (forget (AlgebraCat R)).obj Y),\n ((fun X A => (FreeAlgebra.lift R).symm) X' Y).symm (f ≫ g) =\n (free R).map f ≫ ((fun X A => (FreeAlgebra.lift R).symm) X Y).symm g","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n ","nextTactic":"intros","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"R : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX'✝ X✝ : Type u\nY✝ : AlgebraCat R\nf✝ : X'✝ ⟶ X✝\ng✝ : X✝ ⟶ (forget (AlgebraCat R)).obj Y✝\n⊢ ((fun X A => (FreeAlgebra.lift R).symm) X'✝ Y✝).symm (f✝ ≫ g✝) =\n (free R).map f✝ ≫ ((fun X A => (FreeAlgebra.lift R).symm) X✝ Y✝).symm g✝","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; ","nextTactic":"apply FreeAlgebra.hom_ext","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"case w\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX'✝ X✝ : Type u\nY✝ : AlgebraCat R\nf✝ : X'✝ ⟶ X✝\ng✝ : X✝ ⟶ (forget (AlgebraCat R)).obj Y✝\n⊢ ⇑(((fun X A => (FreeAlgebra.lift R).symm) X'✝ Y✝).symm (f✝ ≫ g✝)) ∘ FreeAlgebra.ι R =\n ⇑((free R).map f✝ ≫ ((fun X A => (FreeAlgebra.lift R).symm) X✝ Y✝).symm g✝) ∘ FreeAlgebra.ι R","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; ","nextTactic":"simp only [FreeAlgebra.ι_comp_lift]","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"case w\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX'✝ X✝ : Type u\nY✝ : AlgebraCat R\nf✝ : X'✝ ⟶ X✝\ng✝ : X✝ ⟶ (forget (AlgebraCat R)).obj Y✝\n⊢ ⇑((FreeAlgebra.lift R).symm.symm (f✝ ≫ g✝)) ∘ FreeAlgebra.ι R =\n ⇑((free R).map f✝ ≫ (FreeAlgebra.lift R).symm.symm g✝) ∘ FreeAlgebra.ι R","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ","nextTactic":"ext1","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"case w.h\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX'✝ X✝ : Type u\nY✝ : AlgebraCat R\nf✝ : X'✝ ⟶ X✝\ng✝ : X✝ ⟶ (forget (AlgebraCat R)).obj Y✝\nx✝ : X'✝\n⊢ (⇑((FreeAlgebra.lift R).symm.symm (f✝ ≫ g✝)) ∘ FreeAlgebra.ι R) x✝ =\n (⇑((free R).map f✝ ≫ (FreeAlgebra.lift R).symm.symm g✝) ∘ FreeAlgebra.ι R) x✝","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n ","nextTactic":"simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"case w.h\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX'✝ X✝ : Type u\nY✝ : AlgebraCat R\nf✝ : X'✝ ⟶ X✝\ng✝ : X✝ ⟶ (forget (AlgebraCat R)).obj Y✝\nx✝ : X'✝\n⊢ ((FreeAlgebra.lift R) (f✝ ≫ g✝)) (FreeAlgebra.ι R x✝) =\n ((FreeAlgebra.lift R) (FreeAlgebra.ι R ∘ f✝) ≫ (FreeAlgebra.lift R) g✝) (FreeAlgebra.ι R x✝)","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n ","nextTactic":"erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_��_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"case w.h\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX'✝ X✝ : Type u\nY✝ : AlgebraCat R\nf✝ : X'✝ ⟶ X✝\ng✝ : X✝ ⟶ (forget (AlgebraCat R)).obj Y✝\nx✝ : X'✝\n⊢ (f✝ ≫ g✝) x✝ = g✝ (f✝ x✝)","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n ","nextTactic":"rfl","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"R : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\n⊢ ∀ {X : Type u} {Y Y' : AlgebraCat R} (f : (free R).obj X ⟶ Y) (g : Y ⟶ Y'),\n ((fun X A => (FreeAlgebra.lift R).symm) X Y') (f ≫ g) =\n ((fun X A => (FreeAlgebra.lift R).symm) X Y) f ≫ (forget (AlgebraCat R)).map g","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n ","nextTactic":"intros","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"R : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ : Type u\nY✝ Y'✝ : AlgebraCat R\nf✝ : (free R).obj X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Y'✝\n⊢ ((fun X A => (FreeAlgebra.lift R).symm) X✝ Y'✝) (f✝ ≫ g✝) =\n ((fun X A => (FreeAlgebra.lift R).symm) X✝ Y✝) f✝ ≫ (forget (AlgebraCat R)).map g✝","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ","nextTactic":"ext","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"case h\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ : Type u\nY✝ Y'✝ : AlgebraCat R\nf✝ : (free R).obj X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Y'✝\na✝ : X✝\n⊢ ((fun X A => (FreeAlgebra.lift R).symm) X✝ Y'✝) (f✝ ≫ g✝) a✝ =\n (((fun X A => (FreeAlgebra.lift R).symm) X✝ Y✝) f✝ ≫ (forget (AlgebraCat R)).map g✝) a✝","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n ","nextTactic":"simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"case h\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ : Type u\nY✝ Y'✝ : AlgebraCat R\nf✝ : (free R).obj X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Y'✝\na✝ : X✝\n⊢ (FreeAlgebra.lift R).symm (f✝ ≫ g✝) a✝ = (forget (AlgebraCat R)).map g✝ ((FreeAlgebra.lift R).symm f✝ a✝)","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n ","nextTactic":"erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"case h\nR : Type u\ninst✝ : CommRing R\nM N U : ModuleCat R\nX✝ : Type u\nY✝ Y'✝ : AlgebraCat R\nf✝ : (free R).obj X✝ ⟶ Y✝\ng✝ : Y✝ ⟶ Y'✝\na✝ : X✝\n⊢ (⇑(f✝ ≫ g✝) ∘ FreeAlgebra.ι R) a✝ = (forget (AlgebraCat R)).map g✝ ((⇑f✝ ∘ FreeAlgebra.ι R) a✝)","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget���_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n ","nextTactic":"rfl","declUpToTactic":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.167_0.H48YBh5wPSCwfA0","decl":"/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\ng₁ : Ring X₁\ng₂ : Ring X₂\nm₁ : Algebra R X₁\nm₂ : Algebra R X₂\ne : X₁ ≃ₐ[R] X₂\n⊢ ↑e ≫ ↑(symm e) = 𝟙 (AlgebraCat.of R X₁)","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ","nextTactic":"ext x","declUpToTactic":"/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.199_0.H48YBh5wPSCwfA0","decl":"/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom "} +{"state":"case w\nR : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\ng₁ : Ring X₁\ng₂ : Ring X₂\nm₁ : Algebra R X₁\nm₂ : Algebra R X₂\ne : X₁ ≃ₐ[R] X₂\nx : (forget (AlgebraCat R)).obj (AlgebraCat.of R X₁)\n⊢ (↑e ≫ ↑(symm e)) x = (𝟙 (AlgebraCat.of R X₁)) x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; ","nextTactic":"exact e.left_inv x","declUpToTactic":"/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.199_0.H48YBh5wPSCwfA0","decl":"/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\ng₁ : Ring X₁\ng₂ : Ring X₂\nm₁ : Algebra R X₁\nm₂ : Algebra R X₂\ne : X₁ ≃ₐ[R] X₂\n⊢ ↑(symm e) ≫ ↑e = 𝟙 (AlgebraCat.of R X₂)","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ","nextTactic":"ext x","declUpToTactic":"/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.199_0.H48YBh5wPSCwfA0","decl":"/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom "} +{"state":"case w\nR : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\ng₁ : Ring X₁\ng₂ : Ring X₂\nm₁ : Algebra R X₁\nm₂ : Algebra R X₂\ne : X₁ ≃ₐ[R] X₂\nx : (forget (AlgebraCat R)).obj (AlgebraCat.of R X₂)\n⊢ (↑(symm e) ≫ ↑e) x = (𝟙 (AlgebraCat.of R X₂)) x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; ","nextTactic":"exact e.right_inv x","declUpToTactic":"/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.199_0.H48YBh5wPSCwfA0","decl":"/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\nX Y : AlgebraCat R\ni : X ≅ Y\nx : ↑X\n⊢ i.inv (i.hom x) = x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; exact e.right_inv x\n#align alg_equiv.to_Algebra_iso AlgEquiv.toAlgebraIso\n\nnamespace CategoryTheory.Iso\n\n/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n ","nextTactic":"change (i.hom ≫ i.inv) x = x","declUpToTactic":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.211_0.H48YBh5wPSCwfA0","decl":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\nX Y : AlgebraCat R\ni : X ≅ Y\nx : ↑X\n⊢ (i.hom ≫ i.inv) x = x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; exact e.right_inv x\n#align alg_equiv.to_Algebra_iso AlgEquiv.toAlgebraIso\n\nnamespace CategoryTheory.Iso\n\n/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n ","nextTactic":"simp only [hom_inv_id]","declUpToTactic":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.211_0.H48YBh5wPSCwfA0","decl":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\nX Y : AlgebraCat R\ni : X ≅ Y\nx : ↑X\n⊢ (𝟙 X) x = x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; exact e.right_inv x\n#align alg_equiv.to_Algebra_iso AlgEquiv.toAlgebraIso\n\nnamespace CategoryTheory.Iso\n\n/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n ","nextTactic":"erw [id_apply]","declUpToTactic":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.211_0.H48YBh5wPSCwfA0","decl":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\nX Y : AlgebraCat R\ni : X ≅ Y\nx : ↑Y\n⊢ i.hom (i.inv x) = x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; exact e.right_inv x\n#align alg_equiv.to_Algebra_iso AlgEquiv.toAlgebraIso\n\nnamespace CategoryTheory.Iso\n\n/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n right_inv x := by\n -- porting note: was `by tidy`\n ","nextTactic":"change (i.inv ≫ i.hom) x = x","declUpToTactic":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n right_inv x := by\n -- porting note: was `by tidy`\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.211_0.H48YBh5wPSCwfA0","decl":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\nX Y : AlgebraCat R\ni : X ≅ Y\nx : ↑Y\n⊢ (i.inv ≫ i.hom) x = x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; exact e.right_inv x\n#align alg_equiv.to_Algebra_iso AlgEquiv.toAlgebraIso\n\nnamespace CategoryTheory.Iso\n\n/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n right_inv x := by\n -- porting note: was `by tidy`\n change (i.inv ≫ i.hom) x = x\n ","nextTactic":"simp only [inv_hom_id]","declUpToTactic":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n right_inv x := by\n -- porting note: was `by tidy`\n change (i.inv ≫ i.hom) x = x\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.211_0.H48YBh5wPSCwfA0","decl":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\nX Y : AlgebraCat R\ni : X ≅ Y\nx : ↑Y\n⊢ (𝟙 Y) x = x","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; exact e.right_inv x\n#align alg_equiv.to_Algebra_iso AlgEquiv.toAlgebraIso\n\nnamespace CategoryTheory.Iso\n\n/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n right_inv x := by\n -- porting note: was `by tidy`\n change (i.inv ≫ i.hom) x = x\n simp only [inv_hom_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n ","nextTactic":"erw [id_apply]","declUpToTactic":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n right_inv x := by\n -- porting note: was `by tidy`\n change (i.inv ≫ i.hom) x = x\n simp only [inv_hom_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.211_0.H48YBh5wPSCwfA0","decl":"/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\nX Y : AlgebraCat R\nf : X ⟶ Y\nx✝ : IsIso ((forget (AlgebraCat R)).map f)\n⊢ IsIso f","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; exact e.right_inv x\n#align alg_equiv.to_Algebra_iso AlgEquiv.toAlgebraIso\n\nnamespace CategoryTheory.Iso\n\n/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n right_inv x := by\n -- porting note: was `by tidy`\n change (i.inv ≫ i.hom) x = x\n simp only [inv_hom_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n map_add' := i.hom.map_add -- Porting note: was `by tidy`\n map_mul' := i.hom.map_mul -- Porting note: was `by tidy`\n commutes' := i.hom.commutes -- Porting note: was `by tidy`\n#align category_theory.iso.to_alg_equiv CategoryTheory.Iso.toAlgEquiv\n\nend CategoryTheory.Iso\n\n/-- Algebra equivalences between `Algebra`s are the same as (isomorphic to) isomorphisms in\n`AlgebraCat`. -/\n@[simps]\ndef algEquivIsoAlgebraIso {X Y : Type u} [Ring X] [Ring Y] [Algebra R X] [Algebra R Y] :\n (X ≃ₐ[R] Y) ≅ AlgebraCat.of R X ≅ AlgebraCat.of R Y where\n hom e := e.toAlgebraIso\n inv i := i.toAlgEquiv\n#align alg_equiv_iso_Algebra_iso algEquivIsoAlgebraIso\n\n-- Porting note: changed to `CoeOut`\ninstance (X : Type u) [Ring X] [Algebra R X] : CoeOut (Subalgebra R X) (AlgebraCat R) :=\n ⟨fun N => AlgebraCat.of R N⟩\n\ninstance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where\n reflects {X Y} f _ := by\n ","nextTactic":"let i := asIso ((forget (AlgebraCat.{u} R)).map f)","declUpToTactic":"instance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where\n reflects {X Y} f _ := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.248_0.H48YBh5wPSCwfA0","decl":"instance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where\n reflects {X Y} f _ "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\nX Y : AlgebraCat R\nf : X ⟶ Y\nx✝ : IsIso ((forget (AlgebraCat R)).map f)\ni : (forget (AlgebraCat R)).obj X ≅ (forget (AlgebraCat R)).obj Y := asIso ((forget (AlgebraCat R)).map f)\n⊢ IsIso f","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; exact e.right_inv x\n#align alg_equiv.to_Algebra_iso AlgEquiv.toAlgebraIso\n\nnamespace CategoryTheory.Iso\n\n/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n right_inv x := by\n -- porting note: was `by tidy`\n change (i.inv ≫ i.hom) x = x\n simp only [inv_hom_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n map_add' := i.hom.map_add -- Porting note: was `by tidy`\n map_mul' := i.hom.map_mul -- Porting note: was `by tidy`\n commutes' := i.hom.commutes -- Porting note: was `by tidy`\n#align category_theory.iso.to_alg_equiv CategoryTheory.Iso.toAlgEquiv\n\nend CategoryTheory.Iso\n\n/-- Algebra equivalences between `Algebra`s are the same as (isomorphic to) isomorphisms in\n`AlgebraCat`. -/\n@[simps]\ndef algEquivIsoAlgebraIso {X Y : Type u} [Ring X] [Ring Y] [Algebra R X] [Algebra R Y] :\n (X ≃ₐ[R] Y) ≅ AlgebraCat.of R X ≅ AlgebraCat.of R Y where\n hom e := e.toAlgebraIso\n inv i := i.toAlgEquiv\n#align alg_equiv_iso_Algebra_iso algEquivIsoAlgebraIso\n\n-- Porting note: changed to `CoeOut`\ninstance (X : Type u) [Ring X] [Algebra R X] : CoeOut (Subalgebra R X) (AlgebraCat R) :=\n ⟨fun N => AlgebraCat.of R N⟩\n\ninstance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where\n reflects {X Y} f _ := by\n let i := asIso ((forget (AlgebraCat.{u} R)).map f)\n ","nextTactic":"let e : X ≃ₐ[R] Y := { f, i.toEquiv with }","declUpToTactic":"instance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where\n reflects {X Y} f _ := by\n let i := asIso ((forget (AlgebraCat.{u} R)).map f)\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.248_0.H48YBh5wPSCwfA0","decl":"instance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where\n reflects {X Y} f _ "} +{"state":"R : Type u\ninst✝ : CommRing R\nX₁ X₂ : Type u\nX Y : AlgebraCat R\nf : X ⟶ Y\nx✝ : IsIso ((forget (AlgebraCat R)).map f)\ni : (forget (AlgebraCat R)).obj X ≅ (forget (AlgebraCat R)).obj Y := asIso ((forget (AlgebraCat R)).map f)\ne : ↑X ≃ₐ[R] ↑Y :=\n let src := i.toEquiv;\n {\n toEquiv :=\n { toFun := f.toFun, invFun := src.invFun, left_inv := (_ : Function.LeftInverse src.invFun src.toFun),\n right_inv := (_ : Function.RightInverse src.invFun src.toFun) },\n map_mul' := (_ : ∀ (x y : ↑X), OneHom.toFun (↑↑↑f) (x * y) = OneHom.toFun (↑↑↑f) x * OneHom.toFun (↑↑↑f) y),\n map_add' := (_ : ∀ (x y : ↑X), OneHom.toFun (↑↑↑f) (x + y) = OneHom.toFun (↑↑↑f) x + OneHom.toFun (↑↑↑f) y),\n commutes' := (_ : ∀ (r : R), OneHom.toFun (↑↑↑f) ((algebraMap R ↑X) r) = (algebraMap R ↑Y) r) }\n⊢ IsIso f","srcUpToTactic":"/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.Algebra.Algebra.Subalgebra.Basic\nimport Mathlib.Algebra.FreeAlgebra\nimport Mathlib.Algebra.Category.Ring.Basic\nimport Mathlib.Algebra.Category.ModuleCat.Basic\n\n#align_import algebra.category.Algebra.basic from \"leanprover-community/mathlib\"@\"79ffb5563b56fefdea3d60b5736dad168a9494ab\"\n\n/-!\n# Category instance for algebras over a commutative ring\n\nWe introduce the bundled category `AlgebraCat` of algebras over a fixed commutative ring `R` along\nwith the forgetful functors to `RingCat` and `ModuleCat`. We furthermore show that the functor\nassociating to a type the free `R`-algebra on that type is left adjoint to the forgetful functor.\n-/\n\nset_option linter.uppercaseLean3 false\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nvariable (R : Type u) [CommRing R]\n\n/-- The category of R-algebras and their morphisms. -/\nstructure AlgebraCat where\n carrier : Type v\n [isRing : Ring carrier]\n [isAlgebra : Algebra R carrier]\n#align Algebra AlgebraCat\n\n-- Porting note: typemax hack to fix universe complaints\n/-- An alias for `AlgebraCat.{max u₁ u₂}`, to deal around unification issues.\nSince the universe the ring lives in can be inferred, we put that last. -/\n@[nolint checkUnivs]\nabbrev AlgebraCatMax.{v₁, v₂, u₁} (R : Type u₁) [CommRing R] := AlgebraCat.{max v₁ v₂} R\n\nattribute [instance] AlgebraCat.isRing AlgebraCat.isAlgebra\n\ninitialize_simps_projections AlgebraCat (-isRing, -isAlgebra)\n\nnamespace AlgebraCat\n\ninstance : CoeSort (AlgebraCat R) (Type v) :=\n ⟨AlgebraCat.carrier⟩\n\nattribute [coe] AlgebraCat.carrier\n\ninstance : Category (AlgebraCat.{v} R) where\n Hom A B := A →ₐ[R] B\n id A := AlgHom.id R A\n comp f g := g.comp f\n\ninstance {M N : AlgebraCat.{v} R} : AlgHomClass (M ⟶ N) R M N :=\n AlgHom.algHomClass\n\ninstance : ConcreteCategory.{v} (AlgebraCat.{v} R) where\n forget :=\n { obj := fun R => R\n map := fun f => f.toFun }\n forget_faithful := ⟨fun h => AlgHom.ext (by intros x; dsimp at h; rw [h])⟩\n\ninstance {S : AlgebraCat.{v} R} : Ring ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Ring S.carrier)\n\ninstance {S : AlgebraCat.{v} R} : Algebra R ((forget (AlgebraCat R)).obj S) :=\n (inferInstance : Algebra R S.carrier)\n\ninstance hasForgetToRing : HasForget₂ (AlgebraCat.{v} R) RingCat.{v} where\n forget₂ :=\n { obj := fun A => RingCat.of A\n map := fun f => RingCat.ofHom f.toRingHom }\n#align Algebra.has_forget_to_Ring AlgebraCat.hasForgetToRing\n\ninstance hasForgetToModule : HasForget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R) where\n forget₂ :=\n { obj := fun M => ModuleCat.of R M\n map := fun f => ModuleCat.ofHom f.toLinearMap }\n#align Algebra.has_forget_to_Module AlgebraCat.hasForgetToModule\n\n@[simp]\nlemma forget₂_module_obj (X : AlgebraCat.{v} R) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).obj X = ModuleCat.of R X :=\n rfl\n\n@[simp]\nlemma forget₂_module_map {X Y : AlgebraCat.{v} R} (f : X ⟶ Y) :\n (forget₂ (AlgebraCat.{v} R) (ModuleCat.{v} R)).map f = ModuleCat.ofHom f.toLinearMap :=\n rfl\n\n/-- The object in the category of R-algebras associated to a type equipped with the appropriate\ntypeclasses. -/\ndef of (X : Type v) [Ring X] [Algebra R X] : AlgebraCat.{v} R :=\n ⟨X⟩\n#align Algebra.of AlgebraCat.of\n\n/-- Typecheck a `AlgHom` as a morphism in `AlgebraCat R`. -/\ndef ofHom {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y] [Algebra R Y]\n (f : X →ₐ[R] Y) : of R X ⟶ of R Y :=\n f\n#align Algebra.of_hom AlgebraCat.ofHom\n\n@[simp]\ntheorem ofHom_apply {R : Type u} [CommRing R] {X Y : Type v} [Ring X] [Algebra R X] [Ring Y]\n [Algebra R Y] (f : X →ₐ[R] Y) (x : X) : ofHom f x = f x :=\n rfl\n#align Algebra.of_hom_apply AlgebraCat.ofHom_apply\n\ninstance : Inhabited (AlgebraCat R) :=\n ⟨of R R⟩\n\n@[simp]\ntheorem coe_of (X : Type u) [Ring X] [Algebra R X] : (of R X : Type u) = X :=\n rfl\n#align Algebra.coe_of AlgebraCat.coe_of\n\nvariable {R}\n\n/-- Forgetting to the underlying type and then building the bundled object returns the original\nalgebra. -/\n@[simps]\ndef ofSelfIso (M : AlgebraCat.{v} R) : AlgebraCat.of R M ≅ M where\n hom := 𝟙 M\n inv := 𝟙 M\n#align Algebra.of_self_iso AlgebraCat.ofSelfIso\n\nvariable {M N U : ModuleCat.{v} R}\n\n@[simp]\ntheorem id_apply (m : M) : (𝟙 M : M → M) m = m :=\n rfl\n#align Algebra.id_apply AlgebraCat.id_apply\n\n@[simp]\ntheorem coe_comp (f : M ⟶ N) (g : N ⟶ U) : (f ≫ g : M → U) = g ∘ f :=\n rfl\n#align Algebra.coe_comp AlgebraCat.coe_comp\n\nvariable (R)\n\n/-- The \"free algebra\" functor, sending a type `S` to the free algebra on `S`. -/\n@[simps!]\ndef free : Type u ⥤ AlgebraCat.{u} R where\n obj S :=\n { carrier := FreeAlgebra R S\n isRing := Algebra.semiringToRing R }\n map f := FreeAlgebra.lift _ <| FreeAlgebra.ι _ ∘ f\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n map_id := by intro X; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; rfl\n map_comp := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n -- Porting node: this ↓ `erw` used to be handled by the `simp` below it\n erw [CategoryTheory.coe_comp]\n simp only [CategoryTheory.coe_comp, Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, FreeAlgebra.lift_ι_apply]\n rfl\n#align Algebra.free AlgebraCat.free\n\n/-- The free/forget adjunction for `R`-algebras. -/\ndef adj : free.{u} R ⊣ forget (AlgebraCat.{u} R) :=\n Adjunction.mkOfHomEquiv\n { homEquiv := fun X A => (FreeAlgebra.lift _).symm\n -- Relying on `obviously` to fill out these proofs is very slow :(\n homEquiv_naturality_left_symm := by\n -- porting note: `apply FreeAlgebra.hom_ext` was `ext1`.\n intros; apply FreeAlgebra.hom_ext; simp only [FreeAlgebra.ι_comp_lift]; ext1\n simp only [free_map, Equiv.symm_symm, FreeAlgebra.lift_ι_apply, CategoryTheory.coe_comp,\n Function.comp_apply, types_comp_apply]\n -- Porting node: this ↓ `erw` and `rfl` used to be handled by the `simp` above\n erw [FreeAlgebra.lift_ι_apply, CategoryTheory.comp_apply, FreeAlgebra.lift_ι_apply,\n Function.comp_apply, FreeAlgebra.lift_ι_apply]\n rfl\n homEquiv_naturality_right := by\n intros; ext\n simp only [CategoryTheory.coe_comp, Function.comp_apply,\n FreeAlgebra.lift_symm_apply, types_comp_apply]\n -- Porting note: proof used to be done after this ↑ `simp`; added ↓ two lines\n erw [FreeAlgebra.lift_symm_apply, FreeAlgebra.lift_symm_apply]\n rfl }\n#align Algebra.adj AlgebraCat.adj\n\ninstance : IsRightAdjoint (forget (AlgebraCat.{u} R)) :=\n ⟨_, adj R⟩\n\nend AlgebraCat\n\nvariable {R}\n\nvariable {X₁ X₂ : Type u}\n\n/-- Build an isomorphism in the category `AlgebraCat R` from a `AlgEquiv` between `Algebra`s. -/\n@[simps]\ndef AlgEquiv.toAlgebraIso {g₁ : Ring X₁} {g₂ : Ring X₂} {m₁ : Algebra R X₁} {m₂ : Algebra R X₂}\n (e : X₁ ≃ₐ[R] X₂) : AlgebraCat.of R X₁ ≅ AlgebraCat.of R X₂ where\n hom := (e : X₁ →ₐ[R] X₂)\n inv := (e.symm : X₂ →ₐ[R] X₁)\n hom_inv_id := by ext x; exact e.left_inv x\n inv_hom_id := by ext x; exact e.right_inv x\n#align alg_equiv.to_Algebra_iso AlgEquiv.toAlgebraIso\n\nnamespace CategoryTheory.Iso\n\n/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/\n@[simps]\ndef toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where\n toFun := i.hom\n invFun := i.inv\n left_inv x := by\n -- porting note: was `by tidy`\n change (i.hom ≫ i.inv) x = x\n simp only [hom_inv_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n right_inv x := by\n -- porting note: was `by tidy`\n change (i.inv ≫ i.hom) x = x\n simp only [inv_hom_id]\n -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644\n erw [id_apply]\n map_add' := i.hom.map_add -- Porting note: was `by tidy`\n map_mul' := i.hom.map_mul -- Porting note: was `by tidy`\n commutes' := i.hom.commutes -- Porting note: was `by tidy`\n#align category_theory.iso.to_alg_equiv CategoryTheory.Iso.toAlgEquiv\n\nend CategoryTheory.Iso\n\n/-- Algebra equivalences between `Algebra`s are the same as (isomorphic to) isomorphisms in\n`AlgebraCat`. -/\n@[simps]\ndef algEquivIsoAlgebraIso {X Y : Type u} [Ring X] [Ring Y] [Algebra R X] [Algebra R Y] :\n (X ≃ₐ[R] Y) ≅ AlgebraCat.of R X ≅ AlgebraCat.of R Y where\n hom e := e.toAlgebraIso\n inv i := i.toAlgEquiv\n#align alg_equiv_iso_Algebra_iso algEquivIsoAlgebraIso\n\n-- Porting note: changed to `CoeOut`\ninstance (X : Type u) [Ring X] [Algebra R X] : CoeOut (Subalgebra R X) (AlgebraCat R) :=\n ⟨fun N => AlgebraCat.of R N⟩\n\ninstance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where\n reflects {X Y} f _ := by\n let i := asIso ((forget (AlgebraCat.{u} R)).map f)\n let e : X ≃ₐ[R] Y := { f, i.toEquiv with }\n ","nextTactic":"exact ⟨(IsIso.of_iso e.toAlgebraIso).1⟩","declUpToTactic":"instance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where\n reflects {X Y} f _ := by\n let i := asIso ((forget (AlgebraCat.{u} R)).map f)\n let e : X ≃ₐ[R] Y := { f, i.toEquiv with }\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Category_AlgebraCat_Basic.248_0.H48YBh5wPSCwfA0","decl":"instance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where\n reflects {X Y} f _ "}