diff --git "a/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Algebra_Unitization.jsonl" "b/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Algebra_Unitization.jsonl" new file mode 100644--- /dev/null +++ "b/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Algebra_Unitization.jsonl" @@ -0,0 +1,86 @@ +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Monoid R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nr₁ r₂ : R\n⊢ 0 = r₁ • 0 + r₂ • 0 + 0 * 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n ","nextTactic":"simp only [smul_zero, add_zero, mul_zero]","declUpToTactic":"@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.401_0.A4XKAvGe1tFCfHK","decl":"@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝³ : Semiring R\ninst✝² : AddCommMonoid A\ninst✝¹ : Mul A\ninst✝ : SMulWithZero R A\na₁ a₂ : A\n⊢ a₁ * a₂ = 0 • a₂ + 0 • a₁ + a₁ * a₂","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by ","nextTactic":"simp only [zero_smul, zero_add]","declUpToTactic":"@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.420_0.A4XKAvGe1tFCfHK","decl":"@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nr : R\na : A\n⊢ r • a + 0 • 0 + 0 * a = r • a","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n ","nextTactic":"rw [smul_zero]","declUpToTactic":"theorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.429_0.A4XKAvGe1tFCfHK","decl":"theorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nr : R\na : A\n⊢ r • a + 0 + 0 * a = r • a","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n ","nextTactic":"rw [add_zero]","declUpToTactic":"theorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.429_0.A4XKAvGe1tFCfHK","decl":"theorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nr : R\na : A\n⊢ r • a + 0 * a = r • a","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n ","nextTactic":"rw [zero_mul]","declUpToTactic":"theorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.429_0.A4XKAvGe1tFCfHK","decl":"theorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nr : R\na : A\n⊢ r • a + 0 = r • a","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n ","nextTactic":"rw [add_zero]","declUpToTactic":"theorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.429_0.A4XKAvGe1tFCfHK","decl":"theorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nr : R\na : A\n⊢ 0 • 0 + r • a + a * 0 = r • a","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n ","nextTactic":"rw [smul_zero]","declUpToTactic":"theorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.439_0.A4XKAvGe1tFCfHK","decl":"theorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nr : R\na : A\n⊢ 0 + r • a + a * 0 = r • a","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n ","nextTactic":"rw [zero_add]","declUpToTactic":"theorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.439_0.A4XKAvGe1tFCfHK","decl":"theorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nr : R\na : A\n⊢ r • a + a * 0 = r • a","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n ","nextTactic":"rw [mul_zero]","declUpToTactic":"theorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.439_0.A4XKAvGe1tFCfHK","decl":"theorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nr : R\na : A\n⊢ r • a + 0 = r • a","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n ","nextTactic":"rw [add_zero]","declUpToTactic":"theorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.439_0.A4XKAvGe1tFCfHK","decl":"theorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Monoid R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nsrc✝¹ : One (Unitization R A) := instOne\nsrc✝ : Mul (Unitization R A) := instMul\nx : Unitization R A\n⊢ 1 • x.2 + x.1 • 0 + 0 * x.2 = x.2","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n ","nextTactic":"rw [one_smul]","declUpToTactic":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.449_0.A4XKAvGe1tFCfHK","decl":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Monoid R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nsrc✝¹ : One (Unitization R A) := instOne\nsrc✝ : Mul (Unitization R A) := instMul\nx : Unitization R A\n⊢ x.2 + x.1 • 0 + 0 * x.2 = x.2","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n ","nextTactic":"rw [smul_zero]","declUpToTactic":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.449_0.A4XKAvGe1tFCfHK","decl":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Monoid R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nsrc✝¹ : One (Unitization R A) := instOne\nsrc✝ : Mul (Unitization R A) := instMul\nx : Unitization R A\n⊢ x.2 + 0 + 0 * x.2 = x.2","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n ","nextTactic":"rw [add_zero]","declUpToTactic":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.449_0.A4XKAvGe1tFCfHK","decl":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Monoid R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nsrc✝¹ : One (Unitization R A) := instOne\nsrc✝ : Mul (Unitization R A) := instMul\nx : Unitization R A\n⊢ x.2 + 0 * x.2 = x.2","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n ","nextTactic":"rw [zero_mul]","declUpToTactic":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.449_0.A4XKAvGe1tFCfHK","decl":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Monoid R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nsrc✝¹ : One (Unitization R A) := instOne\nsrc✝ : Mul (Unitization R A) := instMul\nx : Unitization R A\n⊢ x.2 + 0 = x.2","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n ","nextTactic":"rw [add_zero]","declUpToTactic":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.449_0.A4XKAvGe1tFCfHK","decl":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Monoid R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : DistribMulAction R A\nsrc✝¹ : One (Unitization R A) := instOne\nsrc✝ : Mul (Unitization R A) := instMul\nx : Unitization R A\n⊢ x.1 • 0 + 1 • x.2 + x.2 * 0 = x.2","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n ","nextTactic":"rw [smul_zero, zero_add, one_smul, mul_zero, add_zero]","declUpToTactic":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.449_0.A4XKAvGe1tFCfHK","decl":"instance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx₁ x₂ x₃ : Unitization R A\n⊢ x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a��� * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n ","nextTactic":"simp only [smul_add, add_smul, mul_add]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx₁ x₂ x₃ : Unitization R A\n⊢ x₁.1 • x₂.2 + x₁.1 • x₃.2 + (x₂.1 • x₁.2 + x₃.1 • x₁.2) + (x₁.2 * x₂.2 + x₁.2 * x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n ","nextTactic":"abel","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx₁ x₂ x₃ : Unitization R A\n⊢ x₁.1 • x₂.2 + x₁.1 • x₃.2 + (x₂.1 • x₁.2 + x₃.1 • x₁.2) + (x₁.2 * x₂.2 + x₁.2 * x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n ","nextTactic":"abel","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx₁ x₂ x₃ : Unitization R A\n⊢ (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n ","nextTactic":"simp only [add_smul, smul_add, add_mul]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx₁ x₂ x₃ : Unitization R A\n⊢ x₁.1 • x₃.2 + x₂.1 • x₃.2 + (x₃.1 • x₁.2 + x₃.1 • x₂.2) + (x₁.2 * x₃.2 + x₂.2 * x₃.2) =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n ","nextTactic":"abel","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx₁ x₂ x₃ : Unitization R A\n⊢ x₁.1 • x₃.2 + x₂.1 • x₃.2 + (x₃.1 • x₁.2 + x₃.1 • x₂.2) + (x₁.2 * x₃.2 + x₂.2 * x₃.2) =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n ","nextTactic":"abel","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx : Unitization R A\n⊢ 0 • x.2 + x.1 • 0 + 0 * x.2 = 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n ","nextTactic":"rw [zero_smul]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx : Unitization R A\n⊢ 0 + x.1 • 0 + 0 * x.2 = 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n ","nextTactic":"rw [zero_add]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx : Unitization R A\n⊢ x.1 • 0 + 0 * x.2 = 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n ","nextTactic":"rw [smul_zero]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx : Unitization R A\n⊢ 0 + 0 * x.2 = 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n ","nextTactic":"rw [zero_mul]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx : Unitization R A\n⊢ 0 + 0 = 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n ","nextTactic":"rw [add_zero]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx : Unitization R A\n⊢ x.1 • 0 + 0 • x.2 + x.2 * 0 = 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n ","nextTactic":"rw [smul_zero]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx : Unitization R A\n⊢ 0 + 0 • x.2 + x.2 * 0 = 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n ","nextTactic":"rw [zero_add]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx : Unitization R A\n⊢ 0 • x.2 + x.2 * 0 = 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n ","nextTactic":"rw [zero_smul]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx : Unitization R A\n⊢ 0 + x.2 * 0 = 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n ","nextTactic":"rw [mul_zero]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Semiring R\ninst✝¹ : NonUnitalNonAssocSemiring A\ninst✝ : Module R A\nsrc✝¹ : MulOneClass (Unitization R A) := instMulOneClass\nsrc✝ : AddCommMonoid (Unitization R A) := instAddCommMonoid\nx : Unitization R A\n⊢ 0 + 0 = 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n ","nextTactic":"rw [add_zero]","declUpToTactic":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.466_0.A4XKAvGe1tFCfHK","decl":"instance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁴ : CommMonoid R\ninst✝³ : NonUnitalSemiring A\ninst✝² : DistribMulAction R A\ninst✝¹ : IsScalarTower R A A\ninst✝ : SMulCommClass R A A\nsrc✝ : MulOneClass (Unitization R A) := instMulOneClass\nx y z : Unitization R A\n⊢ (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) + (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 + x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n ","nextTactic":"simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]","declUpToTactic":"instance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.499_0.A4XKAvGe1tFCfHK","decl":"instance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁴ : CommMonoid R\ninst✝³ : NonUnitalSemiring A\ninst✝² : DistribMulAction R A\ninst✝¹ : IsScalarTower R A A\ninst✝ : SMulCommClass R A A\nsrc✝ : MulOneClass (Unitization R A) := instMulOneClass\nx y z : Unitization R A\n⊢ (x.1 * y.1) • z.2 + ((z.1 * x.1) • y.2 + (z.1 * y.1) • x.2 + z.1 • (x.2 * y.2)) +\n (x.1 • (y.2 * z.2) + y.1 • (x.2 * z.2) + x.2 * (y.2 * z.2)) =\n (x.1 * y.1) • z.2 + (x.1 * z.1) • y.2 + x.1 • (y.2 * z.2) + (y.1 * z.1) • x.2 +\n (y.1 • (x.2 * z.2) + z.1 • (x.2 * y.2) + x.2 * (y.2 * z.2))","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n ","nextTactic":"rw [mul_comm z.1 x.1]","declUpToTactic":"instance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.499_0.A4XKAvGe1tFCfHK","decl":"instance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁴ : CommMonoid R\ninst✝³ : NonUnitalSemiring A\ninst✝² : DistribMulAction R A\ninst✝¹ : IsScalarTower R A A\ninst✝ : SMulCommClass R A A\nsrc✝ : MulOneClass (Unitization R A) := instMulOneClass\nx y z : Unitization R A\n⊢ (x.1 * y.1) • z.2 + ((x.1 * z.1) • y.2 + (z.1 * y.1) • x.2 + z.1 • (x.2 * y.2)) +\n (x.1 • (y.2 * z.2) + y.1 • (x.2 * z.2) + x.2 * (y.2 * z.2)) =\n (x.1 * y.1) • z.2 + (x.1 * z.1) • y.2 + x.1 • (y.2 * z.2) + (y.1 * z.1) • x.2 +\n (y.1 • (x.2 * z.2) + z.1 • (x.2 * y.2) + x.2 * (y.2 * z.2))","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n ","nextTactic":"rw [mul_comm z.1 y.1]","declUpToTactic":"instance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.499_0.A4XKAvGe1tFCfHK","decl":"instance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁴ : CommMonoid R\ninst✝³ : NonUnitalSemiring A\ninst✝² : DistribMulAction R A\ninst✝¹ : IsScalarTower R A A\ninst✝ : SMulCommClass R A A\nsrc✝ : MulOneClass (Unitization R A) := instMulOneClass\nx y z : Unitization R A\n⊢ (x.1 * y.1) • z.2 + ((x.1 * z.1) • y.2 + (y.1 * z.1) • x.2 + z.1 • (x.2 * y.2)) +\n (x.1 • (y.2 * z.2) + y.1 • (x.2 * z.2) + x.2 * (y.2 * z.2)) =\n (x.1 * y.1) • z.2 + (x.1 * z.1) • y.2 + x.1 • (y.2 * z.2) + (y.1 * z.1) • x.2 +\n (y.1 • (x.2 * z.2) + z.1 • (x.2 * y.2) + x.2 * (y.2 * z.2))","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n ","nextTactic":"abel","declUpToTactic":"instance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.499_0.A4XKAvGe1tFCfHK","decl":"instance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁴ : CommMonoid R\ninst✝³ : NonUnitalSemiring A\ninst✝² : DistribMulAction R A\ninst✝¹ : IsScalarTower R A A\ninst✝ : SMulCommClass R A A\nsrc✝ : MulOneClass (Unitization R A) := instMulOneClass\nx y z : Unitization R A\n⊢ (x.1 * y.1) • z.2 + ((x.1 * z.1) • y.2 + (y.1 * z.1) • x.2 + z.1 • (x.2 * y.2)) +\n (x.1 • (y.2 * z.2) + y.1 • (x.2 * z.2) + x.2 * (y.2 * z.2)) =\n (x.1 * y.1) • z.2 + (x.1 * z.1) • y.2 + x.1 • (y.2 * z.2) + (y.1 * z.1) • x.2 +\n (y.1 • (x.2 * z.2) + z.1 • (x.2 * y.2) + x.2 * (y.2 * z.2))","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a�� a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n ","nextTactic":"abel","declUpToTactic":"instance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.499_0.A4XKAvGe1tFCfHK","decl":"instance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁴ : CommMonoid R\ninst✝³ : NonUnitalCommSemiring A\ninst✝² : DistribMulAction R A\ninst✝¹ : IsScalarTower R A A\ninst✝ : SMulCommClass R A A\nsrc✝ : Monoid (Unitization R A) := instMonoid\nx₁ x₂ : Unitization R A\n⊢ x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n ","nextTactic":"rw [add_comm (x₁.1 • x₂.2), mul_comm]","declUpToTactic":"instance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.514_0.A4XKAvGe1tFCfHK","decl":"instance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : Star R\ninst✝¹ : AddMonoid A\ninst✝ : StarAddMonoid A\nr : R\n⊢ snd (inl (star r)) = snd (star (inl r))","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by ","nextTactic":"simp only [snd_star, star_zero, snd_inl]","declUpToTactic":"@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.577_0.A4XKAvGe1tFCfHK","decl":"@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : AddMonoid R\ninst✝¹ : StarAddMonoid R\ninst✝ : Star A\na : A\n⊢ fst ↑(star a) = fst (star ↑a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by ","nextTactic":"simp only [fst_star, star_zero, fst_inr]","declUpToTactic":"@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.583_0.A4XKAvGe1tFCfHK","decl":"@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁵ : CommSemiring R\ninst✝⁴ : StarRing R\ninst✝³ : AddCommMonoid A\ninst✝² : StarAddMonoid A\ninst✝¹ : Module R A\ninst✝ : StarModule R A\nr : R\nx : Unitization R A\n⊢ fst (star (r • x)) = fst (star r • star x)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by ","nextTactic":"simp","declUpToTactic":"instance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.595_0.A4XKAvGe1tFCfHK","decl":"instance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁵ : CommSemiring R\ninst✝⁴ : StarRing R\ninst✝³ : AddCommMonoid A\ninst✝² : StarAddMonoid A\ninst✝¹ : Module R A\ninst✝ : StarModule R A\nr : R\nx : Unitization R A\n⊢ snd (star (r • x)) = snd (star r • star x)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by ","nextTactic":"simp","declUpToTactic":"instance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.595_0.A4XKAvGe1tFCfHK","decl":"instance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁵ : CommSemiring R\ninst✝⁴ : StarRing R\ninst✝³ : NonUnitalNonAssocSemiring A\ninst✝² : StarRing A\ninst✝¹ : Module R A\ninst✝ : StarModule R A\nsrc✝ : StarAddMonoid (Unitization R A) := instStarAddMonoid\nx y : Unitization R A\n⊢ fst (star (x * y)) = fst (star y * star x)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by ","nextTactic":"simp [-star_mul']","declUpToTactic":"instance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.599_0.A4XKAvGe1tFCfHK","decl":"instance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁵ : CommSemiring R\ninst✝⁴ : StarRing R\ninst✝³ : NonUnitalNonAssocSemiring A\ninst✝² : StarRing A\ninst✝¹ : Module R A\ninst✝ : StarModule R A\nsrc✝ : StarAddMonoid (Unitization R A) := instStarAddMonoid\nx y : Unitization R A\n⊢ snd (star (x * y)) = snd (star y * star x)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by ","nextTactic":"simp [-star_mul', add_comm (star x.fst • star y.snd)]","declUpToTactic":"instance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.599_0.A4XKAvGe1tFCfHK","decl":"instance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nx : Unitization R A\n⊢ { toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0),\n map_add' :=\n (_ : ∀ (x y : S), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) }\n s *\n x =\n x *\n { toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0),\n map_add' :=\n (_ : ∀ (x y : S), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) }\n s","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n ","nextTactic":"induction' x using Unitization.ind with r a","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst��⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nr : R\na : A\n⊢ { toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0),\n map_add' :=\n (_ : ∀ (x y : S), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) }\n s *\n (inl r + ↑a) =\n (inl r + ↑a) *\n { toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0),\n map_add' :=\n (_ : ∀ (x y : S), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) }\n s","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n ","nextTactic":"show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nr : R\na : A\n⊢ inl ((algebraMap S R) s) * (inl r + ↑a) = (inl r + ↑a) * inl ((algebraMap S R) s)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a���)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n ","nextTactic":"rw [mul_add]","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nr : R\na : A\n⊢ inl ((algebraMap S R) s) * inl r + inl ((algebraMap S R) s) * ↑a = (inl r + ↑a) * inl ((algebraMap S R) s)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n ","nextTactic":"rw [add_mul]","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nr : R\na : A\n⊢ inl ((algebraMap S R) s) * inl r + inl ((algebraMap S R) s) * ↑a =\n inl r * inl ((algebraMap S R) s) + ↑a * inl ((algebraMap S R) s)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n ","nextTactic":"rw [inl_mul_inl]","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nr : R\na : A\n⊢ inl ((algebraMap S R) s * r) + inl ((algebraMap S R) s) * ↑a =\n inl r * inl ((algebraMap S R) s) + ↑a * inl ((algebraMap S R) s)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n ","nextTactic":"rw [inl_mul_inl]","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nr : R\na : A\n⊢ inl ((algebraMap S R) s * r) + inl ((algebraMap S R) s) * ↑a =\n inl (r * (algebraMap S R) s) + ↑a * inl ((algebraMap S R) s)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n ","nextTactic":"rw [inl_mul_inr]","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nr : R\na : A\n⊢ inl ((algebraMap S R) s * r) + ↑((algebraMap S R) s • a) =\n inl (r * (algebraMap S R) s) + ↑a * inl ((algebraMap S R) s)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n ","nextTactic":"rw [inr_mul_inl]","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nr : R\na : A\n⊢ inl ((algebraMap S R) s * r) + ↑((algebraMap S R) s • a) = inl (r * (algebraMap S R) s) + ↑((algebraMap S R) s • a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n ","nextTactic":"rw [mul_comm]","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nx : Unitization R A\n⊢ s • x =\n { toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0),\n map_add' :=\n (_ : ∀ (x y : S), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) }\n s *\n x","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n ","nextTactic":"induction' x using Unitization.ind with r a","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nr : R\na : A\n⊢ s • (inl r + ↑a) =\n { toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0),\n map_add' :=\n (_ : ∀ (x y : S), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) }\n s *\n (inl r + ↑a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n ","nextTactic":"show _ = inl (algebraMap S R s) * _","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝⁸ : CommSemiring S\ninst✝⁷ : CommSemiring R\ninst✝⁶ : NonUnitalSemiring A\ninst✝⁵ : Module R A\ninst✝⁴ : IsScalarTower R A A\ninst✝³ : SMulCommClass R A A\ninst✝² : Algebra S R\ninst✝¹ : DistribMulAction S A\ninst✝ : IsScalarTower S R A\nsrc✝ : S →+* Unitization R A := RingHom.comp (inlRingHom R A) (algebraMap S R)\ns : S\nr : R\na : A\n⊢ s • (inl r + ↑a) = inl ((algebraMap S R) s) * (inl r + ↑a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n ","nextTactic":"rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul]","declUpToTactic":"instance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.617_0.A4XKAvGe1tFCfHK","decl":"instance instAlgebra : Algebra S (Unitization R A) "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹³ : CommSemiring S\ninst✝¹² : CommSemiring R\ninst✝¹¹ : NonUnitalSemiring A\ninst✝¹⁰ : Module R A\ninst✝⁹ : SMulCommClass R A A\ninst✝⁸ : IsScalarTower R A A\nB : Type u_4\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra S B\ninst✝⁵ : Algebra S R\ninst✝⁴ : DistribMulAction S A\ninst✝³ : IsScalarTower S R A\nC : Type u_5\ninst✝² : Semiring C\ninst✝¹ : Algebra R C\nF : Type u_6\ninst✝ : AlgHomClass F S (Unitization R A) B\nφ ψ : F\nh : ∀ (a : A), φ ↑a = ψ ↑a\nh' : ∀ (r : R), φ ((algebraMap R (Unitization R A)) r) = ψ ((algebraMap R (Unitization R A)) r)\n⊢ φ = ψ","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n ","nextTactic":"refine FunLike.ext φ ψ (fun x ↦ ?_)","declUpToTactic":"theorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.697_0.A4XKAvGe1tFCfHK","decl":"theorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹³ : CommSemiring S\ninst✝¹² : CommSemiring R\ninst✝¹¹ : NonUnitalSemiring A\ninst✝¹⁰ : Module R A\ninst✝⁹ : SMulCommClass R A A\ninst✝⁸ : IsScalarTower R A A\nB : Type u_4\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra S B\ninst✝⁵ : Algebra S R\ninst✝⁴ : DistribMulAction S A\ninst✝³ : IsScalarTower S R A\nC : Type u_5\ninst✝² : Semiring C\ninst✝¹ : Algebra R C\nF : Type u_6\ninst✝ : AlgHomClass F S (Unitization R A) B\nφ ψ : F\nh : ∀ (a : A), φ ↑a = ψ ↑a\nh' : ∀ (r : R), φ ((algebraMap R (Unitization R A)) r) = ψ ((algebraMap R (Unitization R A)) r)\nx : Unitization R A\n⊢ φ x = ψ x","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n ","nextTactic":"induction x using Unitization.ind","declUpToTactic":"theorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.697_0.A4XKAvGe1tFCfHK","decl":"theorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹³ : CommSemiring S\ninst✝¹² : CommSemiring R\ninst✝¹¹ : NonUnitalSemiring A\ninst✝¹⁰ : Module R A\ninst✝⁹ : SMulCommClass R A A\ninst✝⁸ : IsScalarTower R A A\nB : Type u_4\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra S B\ninst✝⁵ : Algebra S R\ninst✝⁴ : DistribMulAction S A\ninst✝³ : IsScalarTower S R A\nC : Type u_5\ninst✝² : Semiring C\ninst✝¹ : Algebra R C\nF : Type u_6\ninst✝ : AlgHomClass F S (Unitization R A) B\nφ ψ : F\nh : ∀ (a : A), φ ↑a = ψ ↑a\nh' : ∀ (r : R), φ ((algebraMap R (Unitization R A)) r) = ψ ((algebraMap R (Unitization R A)) r)\nr✝ : R\na✝ : A\n⊢ φ (inl r✝ + ↑a✝) = ψ (inl r✝ + ↑a✝)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n ","nextTactic":"simp only [map_add, ← algebraMap_eq_inl, h, h']","declUpToTactic":"theorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.697_0.A4XKAvGe1tFCfHK","decl":"theorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹³ : CommSemiring S\ninst✝¹² : CommSemiring R\ninst✝¹¹ : NonUnitalSemiring A\ninst✝¹⁰ : Module R A\ninst✝⁹ : SMulCommClass R A A\ninst✝⁸ : IsScalarTower R A A\nB : Type u_4\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra S B\ninst✝⁵ : Algebra S R\ninst✝⁴ : DistribMulAction S A\ninst✝³ : IsScalarTower S R A\nC : Type u_5\ninst✝² : Semiring C\ninst✝¹ : Algebra R C\nF : Type u_6\ninst✝ : AlgHomClass F R (Unitization R A) C\nφ ψ : F\nh : ∀ (a : A), φ ↑a = ψ ↑a\nr : R\n⊢ φ ((algebraMap R (Unitization R A)) r) = ψ ((algebraMap R (Unitization R A)) r)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by ","nextTactic":"simp only [AlgHomClass.commutes]","declUpToTactic":"lemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.706_0.A4XKAvGe1tFCfHK","decl":"lemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\n⊢ (fun x => (algebraMap R C) (fst x) + φ (snd x)) 1 = 1","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by ","nextTactic":"simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx y : Unitization R A\n⊢ OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) } x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) } y","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ �� : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n ","nextTactic":"induction' x using Unitization.ind with x_r x_a","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\ny : Unitization R A\nx_r : R\nx_a : A\n⊢ OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n ((inl x_r + ↑x_a) * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (inl x_r + ↑x_a) *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) } y","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n ","nextTactic":"induction' y using Unitization.ind with y_r y_a","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"case h.h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx_r : R\nx_a : A\ny_r : R\ny_a : A\n⊢ OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n ((inl x_r + ↑x_a) * (inl y_r + ↑y_a)) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (inl x_r + ↑x_a) *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (inl y_r + ↑y_a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n ","nextTactic":"simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"case h.h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx_r : R\nx_a : A\ny_r : R\ny_a : A\n⊢ (algebraMap R C) x_r * (algebraMap R C) y_r + (x_r • φ y_a + y_r • φ x_a + φ x_a * φ y_a) =\n ((algebraMap R C) x_r + φ x_a) * ((algebraMap R C) y_r + φ y_a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n ","nextTactic":"rw [add_mul]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"case h.h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx_r : R\nx_a : A\ny_r : R\ny_a : A\n⊢ (algebraMap R C) x_r * (algebraMap R C) y_r + (x_r • φ y_a + y_r • φ x_a + φ x_a * φ y_a) =\n (algebraMap R C) x_r * ((algebraMap R C) y_r + φ y_a) + φ x_a * ((algebraMap R C) y_r + φ y_a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n ","nextTactic":"rw [mul_add]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"case h.h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx_r : R\nx_a : A\ny_r : R\ny_a : A\n⊢ (algebraMap R C) x_r * (algebraMap R C) y_r + (x_r • φ y_a + y_r • φ x_a + φ x_a * φ y_a) =\n (algebraMap R C) x_r * (algebraMap R C) y_r + (algebraMap R C) x_r * φ y_a + φ x_a * ((algebraMap R C) y_r + φ y_a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n ","nextTactic":"rw [mul_add]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"case h.h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx_r : R\nx_a : A\ny_r : R\ny_a : A\n⊢ (algebraMap R C) x_r * (algebraMap R C) y_r + (x_r • φ y_a + y_r • φ x_a + φ x_a * φ y_a) =\n (algebraMap R C) x_r * (algebraMap R C) y_r + (algebraMap R C) x_r * φ y_a +\n (φ x_a * (algebraMap R C) y_r + φ x_a * φ y_a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n ","nextTactic":"rw [← Algebra.commutes _ (φ x_a)]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"case h.h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx_r : R\nx_a : A\ny_r : R\ny_a : A\n⊢ (algebraMap R C) x_r * (algebraMap R C) y_r + (x_r • φ y_a + y_r • φ x_a + φ x_a * φ y_a) =\n (algebraMap R C) x_r * (algebraMap R C) y_r + (algebraMap R C) x_r * φ y_a +\n ((algebraMap R C) y_r * φ x_a + φ x_a * φ y_a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n ","nextTactic":"simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\n⊢ OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n 0 =\n 0","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by ","nextTactic":"simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx y : Unitization R A\n⊢ OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n (x + y) =\n OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n x +\n OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n y","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n ","nextTactic":"induction' x using Unitization.ind with x_r x_a","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\ny : Unitization R A\nx_r : R\nx_a : A\n⊢ OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n (inl x_r + ↑x_a + y) =\n OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n (inl x_r + ↑x_a) +\n OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n y","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n ","nextTactic":"induction' y using Unitization.ind with y_r y_a","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, ��.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"case h.h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx_r : R\nx_a : A\ny_r : R\ny_a : A\n⊢ OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x), map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n (inl x_r + ↑x_a + (inl y_r + ↑y_a)) =\n OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n (inl x_r + ↑x_a) +\n OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n (inl y_r + ↑y_a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n ","nextTactic":"simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"case h.h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx_r : R\nx_a : A\ny_r : R\ny_a : A\n⊢ (algebraMap R C) x_r + (algebraMap R C) y_r + (φ x_a + φ y_a) =\n (algebraMap R C) x_r + φ x_a + ((algebraMap R C) y_r + φ y_a)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n ","nextTactic":"rw [add_add_add_comm]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nr : R\n⊢ OneHom.toFun\n (↑↑{\n toMonoidHom :=\n {\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) },\n map_zero' := (_ : (algebraMap R C) 0 + φ 0 = 0),\n map_add' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n (x + y) =\n OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n x +\n OneHom.toFun\n (↑{\n toOneHom :=\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) },\n map_mul' :=\n (_ :\n ∀ (x y : Unitization R A),\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n (x * y) =\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n x *\n OneHom.toFun\n { toFun := fun x => (algebraMap R C) (fst x) + φ (snd x),\n map_one' := (_ : (algebraMap R C) 1 + φ 0 = 1) }\n y) })\n y) })\n ((algebraMap R (Unitization R A)) r) =\n (algebraMap R C) r","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n ","nextTactic":"simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]","declUpToTactic":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.724_0.A4XKAvGe1tFCfHK","decl":"/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\n⊢ (fun φ => NonUnitalAlgHom.comp (↑φ) (inrNonUnitalAlgHom R A)) (NonUnitalAlgHom.toAlgHom φ) = φ","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ","nextTactic":"ext","declUpToTactic":"/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.753_0.A4XKAvGe1tFCfHK","decl":"/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : A →ₙₐ[R] C\nx✝ : A\n⊢ ((fun φ => NonUnitalAlgHom.comp (↑φ) (inrNonUnitalAlgHom R A)) (NonUnitalAlgHom.toAlgHom φ)) x✝ = φ x✝","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; ","nextTactic":"simp","declUpToTactic":"/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.753_0.A4XKAvGe1tFCfHK","decl":"/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : Unitization R A →ₐ[R] C\n⊢ NonUnitalAlgHom.comp (↑(NonUnitalAlgHom.toAlgHom ((fun φ => NonUnitalAlgHom.comp (↑φ) (inrNonUnitalAlgHom R A)) φ)))\n (inrNonUnitalAlgHom R A) =\n NonUnitalAlgHom.comp (↑φ) (inrNonUnitalAlgHom R A)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ","nextTactic":"ext","declUpToTactic":"/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.753_0.A4XKAvGe1tFCfHK","decl":"/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nφ : Unitization R A →ₐ[R] C\nx✝ : A\n⊢ (NonUnitalAlgHom.comp (↑(NonUnitalAlgHom.toAlgHom ((fun φ => NonUnitalAlgHom.comp (↑φ) (inrNonUnitalAlgHom R A)) φ)))\n (inrNonUnitalAlgHom R A))\n x✝ =\n (NonUnitalAlgHom.comp (↑φ) (inrNonUnitalAlgHom R A)) x✝","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ext; ","nextTactic":"simp","declUpToTactic":"/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ext; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.753_0.A4XKAvGe1tFCfHK","decl":"/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun "} +{"state":"S : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\n⊢ ⇑(NonUnitalAlgHom.toAlgHom 0) = fst","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ext; simp\n#align unitization.lift Unitization.lift\n\ntheorem lift_symm_apply_apply (φ : Unitization R A →ₐ[R] C) (a : A) :\n Unitization.lift.symm φ a = φ a :=\n rfl\n#align unitization.lift_symm_apply Unitization.lift_symm_apply\n\n@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst := by\n ","nextTactic":"ext","declUpToTactic":"@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.768_0.A4XKAvGe1tFCfHK","decl":"@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst "} +{"state":"case h\nS : Type u_1\nR : Type u_2\nA : Type u_3\ninst✝¹² : CommSemiring S\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : Module R A\ninst✝⁸ : SMulCommClass R A A\ninst✝⁷ : IsScalarTower R A A\nB : Type u_4\ninst✝⁶ : Semiring B\ninst✝⁵ : Algebra S B\ninst✝⁴ : Algebra S R\ninst✝³ : DistribMulAction S A\ninst✝² : IsScalarTower S R A\nC : Type u_5\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nx✝ : Unitization R A\n⊢ (NonUnitalAlgHom.toAlgHom 0) x✝ = fst x✝","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ext; simp\n#align unitization.lift Unitization.lift\n\ntheorem lift_symm_apply_apply (φ : Unitization R A →ₐ[R] C) (a : A) :\n Unitization.lift.symm φ a = φ a :=\n rfl\n#align unitization.lift_symm_apply Unitization.lift_symm_apply\n\n@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst := by\n ext\n ","nextTactic":"simp","declUpToTactic":"@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst := by\n ext\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.768_0.A4XKAvGe1tFCfHK","decl":"@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : StarRing R\ninst✝⁹ : NonUnitalSemiring A\ninst✝⁸ : StarRing A\ninst✝⁷ : Module R A\ninst✝⁶ : SMulCommClass R A A\ninst✝⁵ : IsScalarTower R A A\ninst✝⁴ : StarModule R A\ninst✝³ : Semiring C\ninst✝² : Algebra R C\ninst✝¹ : StarRing C\ninst✝ : StarModule R C\nφ : A →⋆ₙₐ[R] C\nx : Unitization R A\n⊢ OneHom.toFun (↑↑↑(lift φ.toNonUnitalAlgHom)) (star x) = star (OneHom.toFun (↑↑↑(lift φ.toNonUnitalAlgHom)) x)","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ext; simp\n#align unitization.lift Unitization.lift\n\ntheorem lift_symm_apply_apply (φ : Unitization R A →ₐ[R] C) (a : A) :\n Unitization.lift.symm φ a = φ a :=\n rfl\n#align unitization.lift_symm_apply Unitization.lift_symm_apply\n\n@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst := by\n ext\n simp\n\nend AlgHom\n\nsection StarAlgHom\n\nvariable {R A C : Type*} [CommSemiring R] [StarRing R] [NonUnitalSemiring A] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [Algebra R C] [StarRing C] [StarModule R C]\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext]\ntheorem starAlgHom_ext {φ ψ : Unitization R A →⋆ₐ[R] C}\n (h : (φ : Unitization R A →⋆ₙₐ[R] C).comp (Unitization.inrNonUnitalStarAlgHom R A) =\n (ψ : Unitization R A →⋆ₙₐ[R] C).comp (Unitization.inrNonUnitalStarAlgHom R A)) :\n φ = ψ :=\n Unitization.algHom_ext'' <| FunLike.congr_fun h\n\n/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=\n{ toFun := fun φ ↦\n { toAlgHom := Unitization.lift φ.toNonUnitalAlgHom\n map_star' := fun x => by\n ","nextTactic":"induction x using Unitization.ind","declUpToTactic":"/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=\n{ toFun := fun φ ↦\n { toAlgHom := Unitization.lift φ.toNonUnitalAlgHom\n map_star' := fun x => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.790_0.A4XKAvGe1tFCfHK","decl":"/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) "} +{"state":"case h\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : StarRing R\ninst✝⁹ : NonUnitalSemiring A\ninst✝⁸ : StarRing A\ninst✝⁷ : Module R A\ninst✝⁶ : SMulCommClass R A A\ninst✝⁵ : IsScalarTower R A A\ninst✝⁴ : StarModule R A\ninst✝³ : Semiring C\ninst✝² : Algebra R C\ninst✝¹ : StarRing C\ninst✝ : StarModule R C\nφ : A →⋆ₙₐ[R] C\nr✝ : R\na✝ : A\n⊢ OneHom.toFun (↑↑↑(lift φ.toNonUnitalAlgHom)) (star (inl r✝ + ↑a✝)) =\n star (OneHom.toFun (↑↑↑(lift φ.toNonUnitalAlgHom)) (inl r✝ + ↑a✝))","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ext; simp\n#align unitization.lift Unitization.lift\n\ntheorem lift_symm_apply_apply (φ : Unitization R A →ₐ[R] C) (a : A) :\n Unitization.lift.symm φ a = φ a :=\n rfl\n#align unitization.lift_symm_apply Unitization.lift_symm_apply\n\n@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst := by\n ext\n simp\n\nend AlgHom\n\nsection StarAlgHom\n\nvariable {R A C : Type*} [CommSemiring R] [StarRing R] [NonUnitalSemiring A] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [Algebra R C] [StarRing C] [StarModule R C]\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext]\ntheorem starAlgHom_ext {φ ψ : Unitization R A →⋆ₐ[R] C}\n (h : (φ : Unitization R A →⋆ₙₐ[R] C).comp (Unitization.inrNonUnitalStarAlgHom R A) =\n (ψ : Unitization R A →⋆ₙₐ[R] C).comp (Unitization.inrNonUnitalStarAlgHom R A)) :\n φ = ψ :=\n Unitization.algHom_ext'' <| FunLike.congr_fun h\n\n/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=\n{ toFun := fun φ ↦\n { toAlgHom := Unitization.lift φ.toNonUnitalAlgHom\n map_star' := fun x => by\n induction x using Unitization.ind\n ","nextTactic":"simp [map_star]","declUpToTactic":"/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=\n{ toFun := fun φ ↦\n { toAlgHom := Unitization.lift φ.toNonUnitalAlgHom\n map_star' := fun x => by\n induction x using Unitization.ind\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.790_0.A4XKAvGe1tFCfHK","decl":"/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : StarRing R\ninst✝⁹ : NonUnitalSemiring A\ninst✝⁸ : StarRing A\ninst✝⁷ : Module R A\ninst✝⁶ : SMulCommClass R A A\ninst✝⁵ : IsScalarTower R A A\ninst✝⁴ : StarModule R A\ninst✝³ : Semiring C\ninst✝² : Algebra R C\ninst✝¹ : StarRing C\ninst✝ : StarModule R C\nφ : A →⋆ₙₐ[R] C\n⊢ (fun φ => NonUnitalStarAlgHom.comp (StarAlgHom.toNonUnitalStarAlgHom φ) (inrNonUnitalStarAlgHom R A))\n ((fun φ =>\n { toAlgHom := lift φ.toNonUnitalAlgHom,\n map_star' :=\n (_ :\n ∀ (x : Unitization R A),\n OneHom.toFun (↑↑↑(lift φ.toNonUnitalAlgHom)) (star x) =\n star (OneHom.toFun (↑↑↑(lift φ.toNonUnitalAlgHom)) x)) })\n φ) =\n φ","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ext; simp\n#align unitization.lift Unitization.lift\n\ntheorem lift_symm_apply_apply (φ : Unitization R A →ₐ[R] C) (a : A) :\n Unitization.lift.symm φ a = φ a :=\n rfl\n#align unitization.lift_symm_apply Unitization.lift_symm_apply\n\n@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst := by\n ext\n simp\n\nend AlgHom\n\nsection StarAlgHom\n\nvariable {R A C : Type*} [CommSemiring R] [StarRing R] [NonUnitalSemiring A] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [Algebra R C] [StarRing C] [StarModule R C]\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext]\ntheorem starAlgHom_ext {φ ψ : Unitization R A →⋆ₐ[R] C}\n (h : (φ : Unitization R A →⋆ₙₐ[R] C).comp (Unitization.inrNonUnitalStarAlgHom R A) =\n (ψ : Unitization R A →⋆ₙₐ[R] C).comp (Unitization.inrNonUnitalStarAlgHom R A)) :\n φ = ψ :=\n Unitization.algHom_ext'' <| FunLike.congr_fun h\n\n/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=\n{ toFun := fun φ ↦\n { toAlgHom := Unitization.lift φ.toNonUnitalAlgHom\n map_star' := fun x => by\n induction x using Unitization.ind\n simp [map_star] }\n invFun := fun φ ↦ φ.toNonUnitalStarAlgHom.comp (inrNonUnitalStarAlgHom R A),\n left_inv := fun φ => by ","nextTactic":"ext","declUpToTactic":"/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=\n{ toFun := fun φ ↦\n { toAlgHom := Unitization.lift φ.toNonUnitalAlgHom\n map_star' := fun x => by\n induction x using Unitization.ind\n simp [map_star] }\n invFun := fun φ ↦ φ.toNonUnitalStarAlgHom.comp (inrNonUnitalStarAlgHom R A),\n left_inv := fun φ => by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.790_0.A4XKAvGe1tFCfHK","decl":"/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) "} +{"state":"case h\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : StarRing R\ninst✝⁹ : NonUnitalSemiring A\ninst✝⁸ : StarRing A\ninst✝⁷ : Module R A\ninst✝⁶ : SMulCommClass R A A\ninst✝⁵ : IsScalarTower R A A\ninst✝⁴ : StarModule R A\ninst✝³ : Semiring C\ninst✝² : Algebra R C\ninst✝¹ : StarRing C\ninst✝ : StarModule R C\nφ : A →⋆ₙₐ[R] C\nx✝ : A\n⊢ ((fun φ => NonUnitalStarAlgHom.comp (StarAlgHom.toNonUnitalStarAlgHom φ) (inrNonUnitalStarAlgHom R A))\n ((fun φ =>\n { toAlgHom := lift φ.toNonUnitalAlgHom,\n map_star' :=\n (_ :\n ∀ (x : Unitization R A),\n OneHom.toFun (↑↑↑(lift φ.toNonUnitalAlgHom)) (star x) =\n star (OneHom.toFun (↑↑↑(lift φ.toNonUnitalAlgHom)) x)) })\n φ))\n x✝ =\n φ x✝","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((���) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ext; simp\n#align unitization.lift Unitization.lift\n\ntheorem lift_symm_apply_apply (φ : Unitization R A →ₐ[R] C) (a : A) :\n Unitization.lift.symm φ a = φ a :=\n rfl\n#align unitization.lift_symm_apply Unitization.lift_symm_apply\n\n@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst := by\n ext\n simp\n\nend AlgHom\n\nsection StarAlgHom\n\nvariable {R A C : Type*} [CommSemiring R] [StarRing R] [NonUnitalSemiring A] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [Algebra R C] [StarRing C] [StarModule R C]\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext]\ntheorem starAlgHom_ext {φ ψ : Unitization R A →⋆ₐ[R] C}\n (h : (φ : Unitization R A →⋆ₙₐ[R] C).comp (Unitization.inrNonUnitalStarAlgHom R A) =\n (ψ : Unitization R A →⋆ₙₐ[R] C).comp (Unitization.inrNonUnitalStarAlgHom R A)) :\n φ = ψ :=\n Unitization.algHom_ext'' <| FunLike.congr_fun h\n\n/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=\n{ toFun := fun φ ↦\n { toAlgHom := Unitization.lift φ.toNonUnitalAlgHom\n map_star' := fun x => by\n induction x using Unitization.ind\n simp [map_star] }\n invFun := fun φ ↦ φ.toNonUnitalStarAlgHom.comp (inrNonUnitalStarAlgHom R A),\n left_inv := fun φ => by ext; ","nextTactic":"simp","declUpToTactic":"/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=\n{ toFun := fun φ ↦\n { toAlgHom := Unitization.lift φ.toNonUnitalAlgHom\n map_star' := fun x => by\n induction x using Unitization.ind\n simp [map_star] }\n invFun := fun φ ↦ φ.toNonUnitalStarAlgHom.comp (inrNonUnitalStarAlgHom R A),\n left_inv := fun φ => by ext; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.790_0.A4XKAvGe1tFCfHK","decl":"/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : StarRing R\ninst✝⁹ : NonUnitalSemiring A\ninst✝⁸ : StarRing A\ninst✝⁷ : Module R A\ninst✝⁶ : SMulCommClass R A A\ninst✝⁵ : IsScalarTower R A A\ninst✝⁴ : StarModule R A\ninst✝³ : Semiring C\ninst✝² : Algebra R C\ninst✝¹ : StarRing C\ninst✝ : StarModule R C\nφ : Unitization R A →⋆ₐ[R] C\n⊢ ∀ (a : A),\n ((fun φ =>\n { toAlgHom := lift φ.toNonUnitalAlgHom,\n map_star' :=\n (_ :\n ∀ (x : Unitization R A),\n OneHom.toFun (↑↑↑(lift φ.toNonUnitalAlgHom)) (star x) =\n star (OneHom.toFun (↑↑↑(lift φ.toNonUnitalAlgHom)) x)) })\n ((fun φ => NonUnitalStarAlgHom.comp (StarAlgHom.toNonUnitalStarAlgHom φ) (inrNonUnitalStarAlgHom R A)) φ))\n ↑a =\n φ ↑a","srcUpToTactic":"/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\nimport Mathlib.Algebra.Algebra.Basic\nimport Mathlib.Algebra.Algebra.NonUnitalHom\nimport Mathlib.Algebra.Star.Module\nimport Mathlib.Algebra.Star.StarAlgHom\nimport Mathlib.LinearAlgebra.Prod\n\n#align_import algebra.algebra.unitization from \"leanprover-community/mathlib\"@\"8f66240cab125b938b327d3850169d490cfbcdd8\"\n\n/-!\n# Unitization of a non-unital algebra\n\nGiven a non-unital `R`-algebra `A` (given via the type classes\n`[NonUnitalRing A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]`) we construct\nthe minimal unital `R`-algebra containing `A` as an ideal. This object `Unitization R A` is\na type synonym for `R × A` on which we place a different multiplicative structure, namely,\n`(r₁, a₁) * (r₂, a₂) = (r₁ * r₂, r₁ • a₂ + r₂ • a₁ + a₁ * a₂)` where the multiplicative identity\nis `(1, 0)`.\n\nNote, when `A` is a *unital* `R`-algebra, then `Unitization R A` constructs a new multiplicative\nidentity different from the old one, and so in general `Unitization R A` and `A` will not be\nisomorphic even in the unital case. This approach actually has nice functorial properties.\n\nThere is a natural coercion from `A` to `Unitization R A` given by `fun a ↦ (0, a)`, the image\nof which is a proper ideal (TODO), and when `R` is a field this ideal is maximal. Moreover,\nthis ideal is always an essential ideal (it has nontrivial intersection with every other nontrivial\nideal).\n\nEvery non-unital algebra homomorphism from `A` into a *unital* `R`-algebra `B` has a unique\nextension to a (unital) algebra homomorphism from `Unitization R A` to `B`.\n\n## Main definitions\n\n* `Unitization R A`: the unitization of a non-unital `R`-algebra `A`.\n* `Unitization.algebra`: the unitization of `A` as a (unital) `R`-algebra.\n* `Unitization.coeNonUnitalAlgHom`: coercion as a non-unital algebra homomorphism.\n* `NonUnitalAlgHom.toAlgHom φ`: the extension of a non-unital algebra homomorphism `φ : A → B`\n into a unital `R`-algebra `B` to an algebra homomorphism `Unitization R A →ₐ[R] B`.\n* `Unitization.lift`: the universal property of the unitization, the extension\n `NonUnitalAlgHom.toAlgHom` actually implements an equivalence\n `(A →ₙₐ[R] B) ≃ (Unitization R A ≃ₐ[R] B)`\n\n## Main results\n\n* `AlgHom.ext'`: an extensionality lemma for algebra homomorphisms whose domain is\n `Unitization R A`; it suffices that they agree on `A`.\n\n## TODO\n\n* prove the unitization operation is a functor between the appropriate categories\n* prove the image of the coercion is an essential ideal, maximal if scalars are a field.\n-/\n\n\n/-- The minimal unitization of a non-unital `R`-algebra `A`. This is just a type synonym for\n`R × A`.-/\ndef Unitization (R A : Type*) :=\n R × A\n#align unitization Unitization\n\nnamespace Unitization\n\nsection Basic\n\nvariable {R A : Type*}\n\n/-- The canonical inclusion `R → Unitization R A`. -/\ndef inl [Zero A] (r : R) : Unitization R A :=\n (r, 0)\n#align unitization.inl Unitization.inl\n\n-- porting note: we need a def to which we can attach `@[coe]`\n/-- The canonical inclusion `A → Unitization R A`. -/\n@[coe]\ndef inr [Zero R] (a : A) : Unitization R A :=\n (0, a)\n\ninstance [Zero R] : CoeTC A (Unitization R A) where\n coe := inr\n\n/-- The canonical projection `Unitization R A → R`. -/\ndef fst (x : Unitization R A) : R :=\n x.1\n#align unitization.fst Unitization.fst\n\n/-- The canonical projection `Unitization R A → A`. -/\ndef snd (x : Unitization R A) : A :=\n x.2\n#align unitization.snd Unitization.snd\n\n@[ext]\ntheorem ext {x y : Unitization R A} (h1 : x.fst = y.fst) (h2 : x.snd = y.snd) : x = y :=\n Prod.ext h1 h2\n#align unitization.ext Unitization.ext\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem fst_inl [Zero A] (r : R) : (inl r : Unitization R A).fst = r :=\n rfl\n#align unitization.fst_inl Unitization.fst_inl\n\n@[simp]\ntheorem snd_inl [Zero A] (r : R) : (inl r : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_inl Unitization.snd_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem fst_inr [Zero R] (a : A) : (a : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_coe Unitization.fst_inr\n\n@[simp]\ntheorem snd_inr [Zero R] (a : A) : (a : Unitization R A).snd = a :=\n rfl\n#align unitization.snd_coe Unitization.snd_inr\n\nend\n\ntheorem inl_injective [Zero A] : Function.Injective (inl : R → Unitization R A) :=\n Function.LeftInverse.injective <| fst_inl _\n#align unitization.inl_injective Unitization.inl_injective\n\ntheorem inr_injective [Zero R] : Function.Injective ((↑) : A → Unitization R A) :=\n Function.LeftInverse.injective <| snd_inr _\n#align unitization.coe_injective Unitization.inr_injective\n\ninstance instNontrivialLeft {𝕜 A} [Nontrivial 𝕜] [Nonempty A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_left\n\ninstance instNontrivialRight {𝕜 A} [Nonempty 𝕜] [Nontrivial A] :\n Nontrivial (Unitization 𝕜 A) :=\n nontrivial_prod_right\n\nend Basic\n\n/-! ### Structures inherited from `Prod`\n\nAdditive operators and scalar multiplication operate elementwise. -/\n\n\nsection Additive\n\nvariable {T : Type*} {S : Type*} {R : Type*} {A : Type*}\n\ninstance instInhabited [Inhabited R] [Inhabited A] : Inhabited (Unitization R A) :=\n instInhabitedProd\n\ninstance instZero [Zero R] [Zero A] : Zero (Unitization R A) :=\n Prod.instZero\n\ninstance instAdd [Add R] [Add A] : Add (Unitization R A) :=\n Prod.instAdd\n\ninstance instNeg [Neg R] [Neg A] : Neg (Unitization R A) :=\n Prod.instNeg\n\ninstance instAddSemigroup [AddSemigroup R] [AddSemigroup A] : AddSemigroup (Unitization R A) :=\n Prod.instAddSemigroup\n\ninstance instAddZeroClass [AddZeroClass R] [AddZeroClass A] : AddZeroClass (Unitization R A) :=\n Prod.instAddZeroClass\n\ninstance instAddMonoid [AddMonoid R] [AddMonoid A] : AddMonoid (Unitization R A) :=\n Prod.instAddMonoid\n\ninstance instAddGroup [AddGroup R] [AddGroup A] : AddGroup (Unitization R A) :=\n Prod.instAddGroup\n\ninstance instAddCommSemigroup [AddCommSemigroup R] [AddCommSemigroup A] :\n AddCommSemigroup (Unitization R A) :=\n Prod.instAddCommSemigroup\n\ninstance instAddCommMonoid [AddCommMonoid R] [AddCommMonoid A] : AddCommMonoid (Unitization R A) :=\n Prod.instAddCommMonoid\n\ninstance instAddCommGroup [AddCommGroup R] [AddCommGroup A] : AddCommGroup (Unitization R A) :=\n Prod.instAddCommGroup\n\ninstance instSMul [SMul S R] [SMul S A] : SMul S (Unitization R A) :=\n Prod.smul\n\ninstance instIsScalarTower [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMul T S]\n [IsScalarTower T S R] [IsScalarTower T S A] : IsScalarTower T S (Unitization R A) :=\n Prod.isScalarTower\n\ninstance instSMulCommClass [SMul T R] [SMul T A] [SMul S R] [SMul S A] [SMulCommClass T S R]\n [SMulCommClass T S A] : SMulCommClass T S (Unitization R A) :=\n Prod.smulCommClass\n\ninstance instIsCentralScalar [SMul S R] [SMul S A] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ A] [IsCentralScalar S R]\n [IsCentralScalar S A] : IsCentralScalar S (Unitization R A) :=\n Prod.isCentralScalar\n\ninstance instMulAction [Monoid S] [MulAction S R] [MulAction S A] : MulAction S (Unitization R A) :=\n Prod.mulAction\n\ninstance instDistribMulAction [Monoid S] [AddMonoid R] [AddMonoid A] [DistribMulAction S R]\n [DistribMulAction S A] : DistribMulAction S (Unitization R A) :=\n Prod.distribMulAction\n\ninstance instModule [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [Module S R] [Module S A] :\n Module S (Unitization R A) :=\n Prod.instModule\n\nvariable (R A) in\n/-- The identity map between `Unitization R A` and `R × A` as an `AddEquiv`. -/\ndef addEquiv [Add R] [Add A] : Unitization R A ≃+ R × A :=\n AddEquiv.refl _\n\n@[simp]\ntheorem fst_zero [Zero R] [Zero A] : (0 : Unitization R A).fst = 0 :=\n rfl\n#align unitization.fst_zero Unitization.fst_zero\n\n@[simp]\ntheorem snd_zero [Zero R] [Zero A] : (0 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_zero Unitization.snd_zero\n\n@[simp]\ntheorem fst_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).fst = x₁.fst + x₂.fst :=\n rfl\n#align unitization.fst_add Unitization.fst_add\n\n@[simp]\ntheorem snd_add [Add R] [Add A] (x₁ x₂ : Unitization R A) : (x₁ + x₂).snd = x₁.snd + x₂.snd :=\n rfl\n#align unitization.snd_add Unitization.snd_add\n\n@[simp]\ntheorem fst_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).fst = -x.fst :=\n rfl\n#align unitization.fst_neg Unitization.fst_neg\n\n@[simp]\ntheorem snd_neg [Neg R] [Neg A] (x : Unitization R A) : (-x).snd = -x.snd :=\n rfl\n#align unitization.snd_neg Unitization.snd_neg\n\n@[simp]\ntheorem fst_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).fst = s • x.fst :=\n rfl\n#align unitization.fst_smul Unitization.fst_smul\n\n@[simp]\ntheorem snd_smul [SMul S R] [SMul S A] (s : S) (x : Unitization R A) : (s • x).snd = s • x.snd :=\n rfl\n#align unitization.snd_smul Unitization.snd_smul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_zero [Zero R] [Zero A] : (inl 0 : Unitization R A) = 0 :=\n rfl\n#align unitization.inl_zero Unitization.inl_zero\n\n@[simp]\ntheorem inl_add [Add R] [AddZeroClass A] (r₁ r₂ : R) :\n (inl (r₁ + r₂) : Unitization R A) = inl r₁ + inl r₂ :=\n ext rfl (add_zero 0).symm\n#align unitization.inl_add Unitization.inl_add\n\n@[simp]\ntheorem inl_neg [Neg R] [AddGroup A] (r : R) : (inl (-r) : Unitization R A) = -inl r :=\n ext rfl neg_zero.symm\n#align unitization.inl_neg Unitization.inl_neg\n\n@[simp]\ntheorem inl_smul [Monoid S] [AddMonoid A] [SMul S R] [DistribMulAction S A] (s : S) (r : R) :\n (inl (s • r) : Unitization R A) = s • inl r :=\n ext rfl (smul_zero s).symm\n#align unitization.inl_smul Unitization.inl_smul\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_zero [Zero R] [Zero A] : ↑(0 : A) = (0 : Unitization R A) :=\n rfl\n#align unitization.coe_zero Unitization.inr_zero\n\n@[simp]\ntheorem inr_add [AddZeroClass R] [Add A] (m₁ m₂ : A) : (↑(m₁ + m₂) : Unitization R A) = m₁ + m₂ :=\n ext (add_zero 0).symm rfl\n#align unitization.coe_add Unitization.inr_add\n\n@[simp]\ntheorem inr_neg [AddGroup R] [Neg A] (m : A) : (↑(-m) : Unitization R A) = -m :=\n ext neg_zero.symm rfl\n#align unitization.coe_neg Unitization.inr_neg\n\n@[simp]\ntheorem inr_smul [Zero R] [Zero S] [SMulWithZero S R] [SMul S A] (r : S) (m : A) :\n (↑(r • m) : Unitization R A) = r • (m : Unitization R A) :=\n ext (smul_zero _).symm rfl\n#align unitization.coe_smul Unitization.inr_smul\n\nend\n\ntheorem inl_fst_add_inr_snd_eq [AddZeroClass R] [AddZeroClass A] (x : Unitization R A) :\n inl x.fst + (x.snd : Unitization R A) = x :=\n ext (add_zero x.1) (zero_add x.2)\n#align unitization.inl_fst_add_coe_snd_eq Unitization.inl_fst_add_inr_snd_eq\n\n/-- To show a property hold on all `Unitization R A` it suffices to show it holds\non terms of the form `inl r + a`.\n\nThis can be used as `induction x using Unitization.ind`. -/\ntheorem ind {R A} [AddZeroClass R] [AddZeroClass A] {P : Unitization R A → Prop}\n (h : ∀ (r : R) (a : A), P (inl r + (a : Unitization R A))) (x) : P x :=\n inl_fst_add_inr_snd_eq x ▸ h x.1 x.2\n#align unitization.ind Unitization.ind\n\n/-- This cannot be marked `@[ext]` as it ends up being used instead of `LinearMap.prod_ext` when\nworking with `R × A`. -/\ntheorem linearMap_ext {N} [Semiring S] [AddCommMonoid R] [AddCommMonoid A] [AddCommMonoid N]\n [Module S R] [Module S A] [Module S N] ⦃f g : Unitization R A →ₗ[S] N⦄\n (hl : ∀ r, f (inl r) = g (inl r)) (hr : ∀ a : A, f a = g a) : f = g :=\n LinearMap.prod_ext (LinearMap.ext hl) (LinearMap.ext hr)\n#align unitization.linear_map_ext Unitization.linearMap_ext\n\nvariable (R A)\n\n/-- The canonical `R`-linear inclusion `A → Unitization R A`. -/\n@[simps apply]\ndef inrHom [Semiring R] [AddCommMonoid A] [Module R A] : A →ₗ[R] Unitization R A :=\n { LinearMap.inr R R A with toFun := (↑) }\n#align unitization.coe_hom Unitization.inrHom\n\n/-- The canonical `R`-linear projection `Unitization R A → A`. -/\n@[simps apply]\ndef sndHom [Semiring R] [AddCommMonoid A] [Module R A] : Unitization R A →ₗ[R] A :=\n { LinearMap.snd _ _ _ with toFun := snd }\n#align unitization.snd_hom Unitization.sndHom\n\nend Additive\n\n/-! ### Multiplicative structure -/\n\n\nsection Mul\n\nvariable {R A : Type*}\n\ninstance instOne [One R] [Zero A] : One (Unitization R A) :=\n ⟨(1, 0)⟩\n\ninstance instMul [Mul R] [Add A] [Mul A] [SMul R A] : Mul (Unitization R A) :=\n ⟨fun x y => (x.1 * y.1, x.1 • y.2 + y.1 • x.2 + x.2 * y.2)⟩\n\n@[simp]\ntheorem fst_one [One R] [Zero A] : (1 : Unitization R A).fst = 1 :=\n rfl\n#align unitization.fst_one Unitization.fst_one\n\n@[simp]\ntheorem snd_one [One R] [Zero A] : (1 : Unitization R A).snd = 0 :=\n rfl\n#align unitization.snd_one Unitization.snd_one\n\n@[simp]\ntheorem fst_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).fst = x₁.fst * x₂.fst :=\n rfl\n#align unitization.fst_mul Unitization.fst_mul\n\n@[simp]\ntheorem snd_mul [Mul R] [Add A] [Mul A] [SMul R A] (x₁ x₂ : Unitization R A) :\n (x₁ * x₂).snd = x₁.fst • x₂.snd + x₂.fst • x₁.snd + x₁.snd * x₂.snd :=\n rfl\n#align unitization.snd_mul Unitization.snd_mul\n\nsection\n\nvariable (A)\n\n@[simp]\ntheorem inl_one [One R] [Zero A] : (inl 1 : Unitization R A) = 1 :=\n rfl\n#align unitization.inl_one Unitization.inl_one\n\n@[simp]\ntheorem inl_mul [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl (r₁ * r₂) : Unitization R A) = inl r₁ * inl r₂ :=\n ext rfl <|\n show (0 : A) = r₁ • (0 : A) + r₂ • (0 : A) + 0 * 0 by\n simp only [smul_zero, add_zero, mul_zero]\n#align unitization.inl_mul Unitization.inl_mul\n\ntheorem inl_mul_inl [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r₁ r₂ : R) :\n (inl r₁ * inl r₂ : Unitization R A) = inl (r₁ * r₂) :=\n (inl_mul A r₁ r₂).symm\n#align unitization.inl_mul_inl Unitization.inl_mul_inl\n\nend\n\nsection\n\nvariable (R)\n\n@[simp]\ntheorem inr_mul [Semiring R] [AddCommMonoid A] [Mul A] [SMulWithZero R A] (a₁ a₂ : A) :\n (↑(a₁ * a₂) : Unitization R A) = a₁ * a₂ :=\n ext (mul_zero _).symm <|\n show a₁ * a₂ = (0 : R) • a₂ + (0 : R) • a₁ + a₁ * a₂ by simp only [zero_smul, zero_add]\n#align unitization.coe_mul Unitization.inr_mul\n\nend\n\ntheorem inl_mul_inr [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : ((inl r : Unitization R A) * a) = ↑(r • a) :=\n ext (mul_zero r) <|\n show r • a + (0 : R) • (0 : A) + 0 * a = r • a by\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n#align unitization.inl_mul_coe Unitization.inl_mul_inr\n\ntheorem inr_mul_inl [Semiring R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] (r : R)\n (a : A) : a * (inl r : Unitization R A) = ↑(r • a) :=\n ext (zero_mul r) <|\n show (0 : R) • (0 : A) + r • a + a * 0 = r • a by\n rw [smul_zero]\n rw [zero_add]\n rw [mul_zero]\n rw [add_zero]\n#align unitization.coe_mul_inl Unitization.inr_mul_inl\n\ninstance instMulOneClass [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] :\n MulOneClass (Unitization R A) :=\n { Unitization.instOne, Unitization.instMul with\n one_mul := fun x =>\n ext (one_mul x.1) <|\n show (1 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = x.2 by\n rw [one_smul]\n rw [smul_zero]\n rw [add_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_one := fun x =>\n ext (mul_one x.1) <|\n show (x.1 • (0 : A)) + (1 : R) • x.2 + x.2 * (0 : A) = x.2 by\n rw [smul_zero, zero_add, one_smul, mul_zero, add_zero] }\n#align unitization.mul_one_class Unitization.instMulOneClass\n\ninstance instNonAssocSemiring [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] :\n NonAssocSemiring (Unitization R A) :=\n { Unitization.instMulOneClass,\n Unitization.instAddCommMonoid with\n zero_mul := fun x =>\n ext (zero_mul x.1) <|\n show (0 : R) • x.2 + x.1 • (0 : A) + 0 * x.2 = 0 by\n rw [zero_smul]\n rw [zero_add]\n rw [smul_zero]\n rw [zero_mul]\n rw [add_zero]\n mul_zero := fun x =>\n ext (mul_zero x.1) <|\n show x.1 • (0 : A) + (0 : R) • x.2 + x.2 * 0 = 0 by\n rw [smul_zero]\n rw [zero_add]\n rw [zero_smul]\n rw [mul_zero]\n rw [add_zero]\n left_distrib := fun x₁ x₂ x₃ =>\n ext (mul_add x₁.1 x₂.1 x₃.1) <|\n show x₁.1 • (x₂.2 + x₃.2) + (x₂.1 + x₃.1) • x₁.2 + x₁.2 * (x₂.2 + x₃.2) =\n x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 + (x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2) by\n simp only [smul_add, add_smul, mul_add]\n abel\n right_distrib := fun x₁ x₂ x₃ =>\n ext (add_mul x₁.1 x₂.1 x₃.1) <|\n show (x₁.1 + x₂.1) • x₃.2 + x₃.1 • (x₁.2 + x₂.2) + (x₁.2 + x₂.2) * x₃.2 =\n x₁.1 • x₃.2 + x₃.1 • x₁.2 + x₁.2 * x₃.2 + (x₂.1 • x₃.2 + x₃.1 • x₂.2 + x₂.2 * x₃.2) by\n simp only [add_smul, smul_add, add_mul]\n abel }\n\ninstance instMonoid [CommMonoid R] [NonUnitalSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : Monoid (Unitization R A) :=\n { Unitization.instMulOneClass with\n mul_assoc := fun x y z =>\n ext (mul_assoc x.1 y.1 z.1) <|\n show (x.1 * y.1) • z.2 + z.1 • (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) +\n (x.1 • y.2 + y.1 • x.2 + x.2 * y.2) * z.2 =\n x.1 • (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) + (y.1 * z.1) • x.2 +\n x.2 * (y.1 • z.2 + z.1 • y.2 + y.2 * z.2) by\n simp only [smul_add, mul_add, add_mul, smul_smul, smul_mul_assoc, mul_smul_comm,\n mul_assoc]\n rw [mul_comm z.1 x.1]\n rw [mul_comm z.1 y.1]\n abel }\n\ninstance instCommMonoid [CommMonoid R] [NonUnitalCommSemiring A] [DistribMulAction R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommMonoid (Unitization R A) :=\n { Unitization.instMonoid with\n mul_comm := fun x₁ x₂ =>\n ext (mul_comm x₁.1 x₂.1) <|\n show x₁.1 • x₂.2 + x₂.1 • x₁.2 + x₁.2 * x₂.2 = x₂.1 • x₁.2 + x₁.1 • x₂.2 + x₂.2 * x₁.2 by\n rw [add_comm (x₁.1 • x₂.2), mul_comm] }\n\ninstance instSemiring [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Semiring (Unitization R A) :=\n { Unitization.instMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instCommSemiring [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] : CommSemiring (Unitization R A) :=\n { Unitization.instCommMonoid, Unitization.instNonAssocSemiring with }\n\ninstance instNonAssocRing [CommRing R] [NonUnitalNonAssocRing A] [Module R A] :\n NonAssocRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instNonAssocSemiring with }\n\ninstance instRing [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : Ring (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instSemiring with }\n\ninstance instCommRing [CommRing R] [NonUnitalCommRing A] [Module R A] [IsScalarTower R A A]\n [SMulCommClass R A A] : CommRing (Unitization R A) :=\n { Unitization.instAddCommGroup, Unitization.instCommSemiring with }\n\nvariable (R A)\n\n/-- The canonical inclusion of rings `R →+* Unitization R A`. -/\n@[simps apply]\ndef inlRingHom [Semiring R] [NonUnitalSemiring A] [Module R A] : R →+* Unitization R A\n where\n toFun := inl\n map_one' := inl_one A\n map_mul' := inl_mul A\n map_zero' := inl_zero A\n map_add' := inl_add A\n#align unitization.inl_ring_hom Unitization.inlRingHom\n\nend Mul\n\n/-! ### Star structure -/\n\n\nsection Star\n\nvariable {R A : Type*}\n\ninstance instStar [Star R] [Star A] : Star (Unitization R A) :=\n ⟨fun ra => (star ra.fst, star ra.snd)⟩\n\n@[simp]\ntheorem fst_star [Star R] [Star A] (x : Unitization R A) : (star x).fst = star x.fst :=\n rfl\n#align unitization.fst_star Unitization.fst_star\n\n@[simp]\ntheorem snd_star [Star R] [Star A] (x : Unitization R A) : (star x).snd = star x.snd :=\n rfl\n#align unitization.snd_star Unitization.snd_star\n\n@[simp]\ntheorem inl_star [Star R] [AddMonoid A] [StarAddMonoid A] (r : R) :\n inl (star r) = star (inl r : Unitization R A) :=\n ext rfl (by simp only [snd_star, star_zero, snd_inl])\n#align unitization.inl_star Unitization.inl_star\n\n@[simp]\ntheorem inr_star [AddMonoid R] [StarAddMonoid R] [Star A] (a : A) :\n ↑(star a) = star (a : Unitization R A) :=\n ext (by simp only [fst_star, star_zero, fst_inr]) rfl\n#align unitization.coe_star Unitization.inr_star\n\ninstance instStarAddMonoid [AddMonoid R] [AddMonoid A] [StarAddMonoid R] [StarAddMonoid A] :\n StarAddMonoid (Unitization R A)\n where\n star_involutive x := ext (star_star x.fst) (star_star x.snd)\n star_add x y := ext (star_add x.fst y.fst) (star_add x.snd y.snd)\n\ninstance instStarModule [CommSemiring R] [StarRing R] [AddCommMonoid A] [StarAddMonoid A]\n [Module R A] [StarModule R A] : StarModule R (Unitization R A) where\n star_smul r x := ext (by simp) (by simp)\n\ninstance instStarRing [CommSemiring R] [StarRing R] [NonUnitalNonAssocSemiring A] [StarRing A]\n [Module R A] [StarModule R A] :\n StarRing (Unitization R A) :=\n { Unitization.instStarAddMonoid with\n star_mul := fun x y =>\n ext (by simp [-star_mul']) (by simp [-star_mul', add_comm (star x.fst • star y.snd)]) }\n\nend Star\n\n/-! ### Algebra structure -/\n\n\nsection Algebra\n\nvariable (S R A : Type*) [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [IsScalarTower R A A] [SMulCommClass R A A] [Algebra S R] [DistribMulAction S A]\n [IsScalarTower S R A]\n\ninstance instAlgebra : Algebra S (Unitization R A) :=\n { (Unitization.inlRingHom R A).comp (algebraMap S R) with\n commutes' := fun s x => by\n induction' x using Unitization.ind with r a\n show inl (algebraMap S R s) * _ = _ * inl (algebraMap S R s)\n rw [mul_add]\n rw [add_mul]\n rw [inl_mul_inl]\n rw [inl_mul_inl]\n rw [inl_mul_inr]\n rw [inr_mul_inl]\n rw [mul_comm]\n smul_def' := fun s x => by\n induction' x using Unitization.ind with r a\n show _ = inl (algebraMap S R s) * _\n rw [mul_add, smul_add,Algebra.algebraMap_eq_smul_one, inl_mul_inl, inl_mul_inr, smul_one_mul,\n inl_smul, inr_smul, smul_one_smul] }\n#align unitization.algebra Unitization.instAlgebra\n\ntheorem algebraMap_eq_inl_comp : ⇑(algebraMap S (Unitization R A)) = inl ∘ algebraMap S R :=\n rfl\n#align unitization.algebra_map_eq_inl_comp Unitization.algebraMap_eq_inl_comp\n\ntheorem algebraMap_eq_inlRingHom_comp :\n algebraMap S (Unitization R A) = (inlRingHom R A).comp (algebraMap S R) :=\n rfl\n#align unitization.algebra_map_eq_inl_ring_hom_comp Unitization.algebraMap_eq_inlRingHom_comp\n\ntheorem algebraMap_eq_inl : ⇑(algebraMap R (Unitization R A)) = inl :=\n rfl\n#align unitization.algebra_map_eq_inl Unitization.algebraMap_eq_inl\n\ntheorem algebraMap_eq_inlRingHom : algebraMap R (Unitization R A) = inlRingHom R A :=\n rfl\n#align unitization.algebra_map_eq_inl_hom Unitization.algebraMap_eq_inlRingHom\n\n/-- The canonical `R`-algebra projection `Unitization R A → R`. -/\n@[simps]\ndef fstHom : Unitization R A →ₐ[R] R where\n toFun := fst\n map_one' := fst_one\n map_mul' := fst_mul\n map_zero' := fst_zero (A := A)\n map_add' := fst_add\n commutes' := fst_inl A\n#align unitization.fst_hom Unitization.fstHom\n\nend Algebra\n\nsection coe\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `Unitization R A`\nrealized as a non-unital algebra homomorphism. -/\n@[simps]\ndef inrNonUnitalAlgHom (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] :\n A →ₙₐ[R] Unitization R A where\n toFun := (↑)\n map_smul' := inr_smul R\n map_zero' := inr_zero R\n map_add' := inr_add R\n map_mul' := inr_mul R\n#align unitization.coe_non_unital_alg_hom Unitization.inrNonUnitalAlgHom\n\n/-- The coercion from a non-unital `R`-algebra `A` to its unitization `unitization R A`\nrealized as a non-unital star algebra homomorphism. -/\n@[simps!]\ndef inrNonUnitalStarAlgHom (R A : Type*) [CommSemiring R] [StarAddMonoid R]\n [NonUnitalSemiring A] [Star A] [Module R A] :\n A →⋆ₙₐ[R] Unitization R A where\n toNonUnitalAlgHom := inrNonUnitalAlgHom R A\n map_star' := inr_star\n\nend coe\n\nsection AlgHom\n\nvariable {S R A : Type*} [CommSemiring S] [CommSemiring R] [NonUnitalSemiring A] [Module R A]\n [SMulCommClass R A A] [IsScalarTower R A A] {B : Type*} [Semiring B] [Algebra S B] [Algebra S R]\n [DistribMulAction S A] [IsScalarTower S R A] {C : Type*} [Semiring C] [Algebra R C]\n\ntheorem algHom_ext {F : Type*} [AlgHomClass F S (Unitization R A) B] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a)\n (h' : ∀ r, φ (algebraMap R (Unitization R A) r) = ψ (algebraMap R (Unitization R A) r)) :\n φ = ψ := by\n refine FunLike.ext φ ψ (fun x ↦ ?_)\n induction x using Unitization.ind\n simp only [map_add, ← algebraMap_eq_inl, h, h']\n#align unitization.alg_hom_ext Unitization.algHom_ext\n\nlemma algHom_ext'' {F : Type*} [AlgHomClass F R (Unitization R A) C] {φ ψ : F}\n (h : ∀ a : A, φ a = ψ a) : φ = ψ :=\n algHom_ext h (fun r => by simp only [AlgHomClass.commutes])\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext 1100]\ntheorem algHom_ext' {φ ψ : Unitization R A →ₐ[R] C}\n (h :\n φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A) =\n ψ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)) :\n φ = ψ :=\n algHom_ext'' (NonUnitalAlgHom.congr_fun h)\n#align unitization.alg_hom_ext' Unitization.algHom_ext'\n\n/- porting note: this was extracted from `Unitization.lift` below, where it had previously\nbeen inlined. Unfortunately, `Unitization.lift` was relatively slow in Lean 3, but in Lean 4 it\njust times out. Note that this doesn't require a backport because this file is a leaf in the\nimport hierarchy. -/\n/-- A non-unital algebra homomorphism from `A` into a unital `R`-algebra `C` lifts to a unital\nalgebra homomorphism from the unitization into `C`. This is extended to an `Equiv` in\n`Unitization.lift` and that should be used instead. This declaration only exists for performance\nreasons. -/\n@[simps]\ndef _root_.NonUnitalAlgHom.toAlgHom (φ :A →ₙₐ[R] C) : Unitization R A →ₐ[R] C where\n toFun := fun x => algebraMap R C x.fst + φ x.snd\n map_one' := by simp only [fst_one, map_one, snd_one, φ.map_zero, add_zero]\n map_mul' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_mul, fst_add, fst_inl, fst_inr, snd_mul, snd_add, snd_inl, snd_inr, add_zero,\n map_mul, zero_add, map_add, map_smul φ]\n rw [add_mul]\n rw [mul_add]\n rw [mul_add]\n rw [← Algebra.commutes _ (φ x_a)]\n simp only [Algebra.algebraMap_eq_smul_one, smul_one_mul, add_assoc]\n map_zero' := by simp only [fst_zero, map_zero, snd_zero, φ.map_zero, add_zero]\n map_add' := fun x y => by\n induction' x using Unitization.ind with x_r x_a\n induction' y using Unitization.ind with y_r y_a\n simp only [fst_add, fst_inl, fst_inr, add_zero, map_add, snd_add, snd_inl, snd_inr,\n zero_add, φ.map_add]\n rw [add_add_add_comm]\n commutes' := fun r => by\n simp only [algebraMap_eq_inl, fst_inl, snd_inl, φ.map_zero, add_zero]\n\n\n/-- Non-unital algebra homomorphisms from `A` into a unital `R`-algebra `C` lift uniquely to\n`Unitization R A →ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef lift : (A →ₙₐ[R] C) ≃ (Unitization R A →ₐ[R] C) where\n toFun := NonUnitalAlgHom.toAlgHom\n invFun φ := φ.toNonUnitalAlgHom.comp (inrNonUnitalAlgHom R A)\n left_inv φ := by ext; simp\n right_inv φ := Unitization.algHom_ext' <| by ext; simp\n#align unitization.lift Unitization.lift\n\ntheorem lift_symm_apply_apply (φ : Unitization R A →ₐ[R] C) (a : A) :\n Unitization.lift.symm φ a = φ a :=\n rfl\n#align unitization.lift_symm_apply Unitization.lift_symm_apply\n\n@[simp]\nlemma _root_.NonUnitalAlgHom.toAlgHom_zero :\n ⇑(0 : A →ₙₐ[R] R).toAlgHom = Unitization.fst := by\n ext\n simp\n\nend AlgHom\n\nsection StarAlgHom\n\nvariable {R A C : Type*} [CommSemiring R] [StarRing R] [NonUnitalSemiring A] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [Algebra R C] [StarRing C] [StarModule R C]\n\n/-- See note [partially-applied ext lemmas] -/\n@[ext]\ntheorem starAlgHom_ext {φ ψ : Unitization R A →⋆ₐ[R] C}\n (h : (φ : Unitization R A →⋆ₙₐ[R] C).comp (Unitization.inrNonUnitalStarAlgHom R A) =\n (ψ : Unitization R A →⋆ₙₐ[R] C).comp (Unitization.inrNonUnitalStarAlgHom R A)) :\n φ = ψ :=\n Unitization.algHom_ext'' <| FunLike.congr_fun h\n\n/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=\n{ toFun := fun φ ↦\n { toAlgHom := Unitization.lift φ.toNonUnitalAlgHom\n map_star' := fun x => by\n induction x using Unitization.ind\n simp [map_star] }\n invFun := fun φ ↦ φ.toNonUnitalStarAlgHom.comp (inrNonUnitalStarAlgHom R A),\n left_inv := fun φ => by ext; simp,\n right_inv := fun φ => Unitization.algHom_ext'' <| by ","nextTactic":"simp","declUpToTactic":"/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=\n{ toFun := fun φ ↦\n { toAlgHom := Unitization.lift φ.toNonUnitalAlgHom\n map_star' := fun x => by\n induction x using Unitization.ind\n simp [map_star] }\n invFun := fun φ ↦ φ.toNonUnitalStarAlgHom.comp (inrNonUnitalStarAlgHom R A),\n left_inv := fun φ => by ext; simp,\n right_inv := fun φ => Unitization.algHom_ext'' <| by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Unitization.790_0.A4XKAvGe1tFCfHK","decl":"/-- Non-unital star algebra homomorphisms from `A` into a unital star `R`-algebra `C` lift uniquely\nto `Unitization R A →⋆ₐ[R] C`. This is the universal property of the unitization. -/\n@[simps! apply symm_apply apply_apply]\ndef starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) "}