diff --git "a/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Algebra_Subalgebra_Unitization.jsonl" "b/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Algebra_Subalgebra_Unitization.jsonl" new file mode 100644--- /dev/null +++ "b/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Algebra_Subalgebra_Unitization.jsonl" @@ -0,0 +1,84 @@ +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : CommSemiring R\ninst✝¹ : Semiring A\ninst✝ : Algebra R A\nS : Subalgebra R A\n⊢ NonUnitalSubalgebra.toSubalgebra (toNonUnitalSubalgebra S) (_ : 1 ∈ S) = S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by ","nextTactic":"cases S","declUpToTactic":"theorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.71_0.vVYVSGoMcyboux2","decl":"theorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S "} +{"state":"case mk\nR : Type u_1\nA : Type u_2\ninst✝² : CommSemiring R\ninst✝¹ : Semiring A\ninst✝ : Algebra R A\ntoSubsemiring✝ : Subsemiring A\nalgebraMap_mem'✝ : ∀ (r : R), (algebraMap R A) r ∈ toSubsemiring✝.carrier\n⊢ NonUnitalSubalgebra.toSubalgebra\n (toNonUnitalSubalgebra { toSubsemiring := toSubsemiring✝, algebraMap_mem' := algebraMap_mem'✝ })\n (_ : 1 ∈ { toSubsemiring := toSubsemiring✝, algebraMap_mem' := algebraMap_mem'✝ }) =\n { toSubsemiring := toSubsemiring✝, algebraMap_mem' := algebraMap_mem'✝ }","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; ","nextTactic":"rfl","declUpToTactic":"theorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.71_0.vVYVSGoMcyboux2","decl":"theorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝² : CommSemiring R\ninst✝¹ : Semiring A\ninst✝ : Algebra R A\nS : NonUnitalSubalgebra R A\nh1 : 1 ∈ S\n⊢ Subalgebra.toNonUnitalSubalgebra (toSubalgebra S h1) = S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n ","nextTactic":"cases S","declUpToTactic":"theorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.74_0.vVYVSGoMcyboux2","decl":"theorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S "} +{"state":"case mk\nR : Type u_1\nA : Type u_2\ninst✝² : CommSemiring R\ninst✝¹ : Semiring A\ninst✝ : Algebra R A\ntoNonUnitalSubsemiring✝ : NonUnitalSubsemiring A\nsmul_mem'✝ : ∀ (c : R) {x : A}, x ∈ toNonUnitalSubsemiring✝.carrier → c • x ∈ toNonUnitalSubsemiring✝.carrier\nh1 : 1 ∈ { toNonUnitalSubsemiring := toNonUnitalSubsemiring✝, smul_mem' := smul_mem'✝ }\n⊢ Subalgebra.toNonUnitalSubalgebra\n (toSubalgebra { toNonUnitalSubsemiring := toNonUnitalSubsemiring✝, smul_mem' := smul_mem'✝ } h1) =\n { toNonUnitalSubsemiring := toNonUnitalSubsemiring✝, smul_mem' := smul_mem'✝ }","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; ","nextTactic":"rfl","declUpToTactic":"theorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.74_0.vVYVSGoMcyboux2","decl":"theorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nS : Subalgebra R C\n⊢ AlgHom.range (lift f) ≤ S ↔ NonUnitalAlgHom.range f ≤ Subalgebra.toNonUnitalSubalgebra S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n ","nextTactic":"refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩","declUpToTactic":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.85_0.vVYVSGoMcyboux2","decl":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra "} +{"state":"case refine_1\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nS : Subalgebra R C\nh : AlgHom.range (lift f) ≤ S\n⊢ NonUnitalAlgHom.range f ≤ Subalgebra.toNonUnitalSubalgebra S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · ","nextTactic":"rintro - ⟨x, rfl⟩","declUpToTactic":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.85_0.vVYVSGoMcyboux2","decl":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra "} +{"state":"case refine_1.intro\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nS : Subalgebra R C\nh : AlgHom.range (lift f) ≤ S\nx : A\n⊢ ↑f x ∈ Subalgebra.toNonUnitalSubalgebra S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n ","nextTactic":"exact @h (f x) ⟨x, by simp⟩","declUpToTactic":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.85_0.vVYVSGoMcyboux2","decl":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nS : Subalgebra R C\nh : AlgHom.range (lift f) ≤ S\nx : A\n⊢ ↑(lift f) ↑x = f x","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by ","nextTactic":"simp","declUpToTactic":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.85_0.vVYVSGoMcyboux2","decl":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra "} +{"state":"case refine_2\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nS : Subalgebra R C\nh : NonUnitalAlgHom.range f ≤ Subalgebra.toNonUnitalSubalgebra S\n⊢ AlgHom.range (lift f) ≤ S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · ","nextTactic":"rintro - ⟨x, rfl⟩","declUpToTactic":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.85_0.vVYVSGoMcyboux2","decl":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra "} +{"state":"case refine_2.intro\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nS : Subalgebra R C\nh : NonUnitalAlgHom.range f ≤ Subalgebra.toNonUnitalSubalgebra S\nx : Unitization R A\n⊢ ↑(lift f) x ∈ S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n ","nextTactic":"induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)","declUpToTactic":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.85_0.vVYVSGoMcyboux2","decl":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra "} +{"state":"case refine_2.intro\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nS : Subalgebra R C\nh : NonUnitalAlgHom.range f ≤ Subalgebra.toNonUnitalSubalgebra S\nx : Unitization R A\n⊢ ↑(lift f) x ∈ S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n ","nextTactic":"induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)","declUpToTactic":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.85_0.vVYVSGoMcyboux2","decl":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra "} +{"state":"case refine_2.intro.h\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nS : Subalgebra R C\nh : NonUnitalAlgHom.range f ≤ Subalgebra.toNonUnitalSubalgebra S\nr : R\na : A\n⊢ ↑(lift f) (inl r + ↑a) ∈ S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n ","nextTactic":"| _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)","declUpToTactic":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.85_0.vVYVSGoMcyboux2","decl":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra "} +{"state":"case refine_2.intro.h\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nS : Subalgebra R C\nh : NonUnitalAlgHom.range f ≤ Subalgebra.toNonUnitalSubalgebra S\nr : R\na : A\n⊢ ↑(lift f) (inl r + ↑a) ∈ S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => ","nextTactic":"simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)","declUpToTactic":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.85_0.vVYVSGoMcyboux2","decl":"theorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nc : Subalgebra R C\n⊢ AlgHom.range (lift f) ≤ c ↔ Algebra.adjoin R ↑(NonUnitalAlgHom.range f) ≤ c","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by ","nextTactic":"rw [lift_range_le, Algebra.adjoin_le_iff]","declUpToTactic":"theorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.94_0.vVYVSGoMcyboux2","decl":"theorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝⁶ : CommSemiring R\ninst✝⁵ : NonUnitalSemiring A\ninst✝⁴ : Module R A\ninst✝³ : SMulCommClass R A A\ninst✝² : IsScalarTower R A A\ninst✝¹ : Semiring C\ninst✝ : Algebra R C\nf : A →ₙₐ[R] C\nc : Subalgebra R C\n⊢ NonUnitalAlgHom.range f ≤ Subalgebra.toNonUnitalSubalgebra c ↔ ↑(NonUnitalAlgHom.range f) ⊆ ↑c","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; ","nextTactic":"rfl","declUpToTactic":"theorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.94_0.vVYVSGoMcyboux2","decl":"theorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : CommSemiring R\ninst✝² : Semiring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubsemiringClass S A\nhSRA : SMulMemClass S R A\ns : S\n⊢ AlgHom.range (unitization s) = Algebra.adjoin R ↑s","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n ","nextTactic":"rw [unitization]","declUpToTactic":"theorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.117_0.vVYVSGoMcyboux2","decl":"theorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : CommSemiring R\ninst✝² : Semiring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubsemiringClass S A\nhSRA : SMulMemClass S R A\ns : S\n⊢ AlgHom.range (Unitization.lift (NonUnitalSubalgebraClass.subtype s)) = Algebra.adjoin R ↑s","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n ","nextTactic":"rw [Unitization.lift_range]","declUpToTactic":"theorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.117_0.vVYVSGoMcyboux2","decl":"theorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : CommSemiring R\ninst✝² : Semiring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubsemiringClass S A\nhSRA : SMulMemClass S R A\ns : S\n⊢ Algebra.adjoin R ↑(NonUnitalAlgHom.range (NonUnitalSubalgebraClass.subtype s)) = Algebra.adjoin R ↑s","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n ","nextTactic":"simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]","declUpToTactic":"theorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.117_0.vVYVSGoMcyboux2","decl":"theorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : CommSemiring R\ninst✝² : Semiring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubsemiringClass S A\nhSRA : SMulMemClass S R A\ns : S\n⊢ Algebra.adjoin R {x | x ∈ s} = Algebra.adjoin R ↑s","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n ","nextTactic":"rfl","declUpToTactic":"theorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.117_0.vVYVSGoMcyboux2","decl":"theorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) "} +{"state":"F : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : CommRing R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh : ∀ (r : R), r ≠ 0 → (algebraMap R A) r ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\n⊢ Function.Injective ⇑f","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n ","nextTactic":"refine' (injective_iff_map_eq_zero _).mpr fun x hx => _","declUpToTactic":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.126_0.vVYVSGoMcyboux2","decl":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"F : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : CommRing R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh : ∀ (r : R), r ≠ 0 → (algebraMap R A) r ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nx : Unitization R ↥s\nhx : f x = 0\n⊢ x = 0","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n ","nextTactic":"induction' x using Unitization.ind with r a","declUpToTactic":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.126_0.vVYVSGoMcyboux2","decl":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"case h\nF : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : CommRing R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh : ∀ (r : R), r ≠ 0 → (algebraMap R A) r ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nr : R\na : ↥s\nhx : f (Unitization.inl r + ↑a) = 0\n⊢ Unitization.inl r + ↑a = 0","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n ","nextTactic":"simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx","declUpToTactic":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.126_0.vVYVSGoMcyboux2","decl":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"case h\nF : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : CommRing R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh : ∀ (r : R), r ≠ 0 → (algebraMap R A) r ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nr : R\na : ↥s\nhx : (algebraMap R A) r + ↑a = 0\n⊢ Unitization.inl r + ↑a = 0","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n ","nextTactic":"rw [add_eq_zero_iff_eq_neg] at hx ⊢","declUpToTactic":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.126_0.vVYVSGoMcyboux2","decl":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"case h\nF : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : CommRing R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh : ∀ (r : R), r ≠ 0 → (algebraMap R A) r ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nr : R\na : ↥s\nhx : (algebraMap R A) r = -↑a\n⊢ Unitization.inl r = -↑a","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n ","nextTactic":"by_cases hr : r = 0","declUpToTactic":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.126_0.vVYVSGoMcyboux2","decl":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"case pos\nF : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : CommRing R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh : ∀ (r : R), r ≠ 0 → (algebraMap R A) r ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nr : R\na : ↥s\nhx : (algebraMap R A) r = -↑a\nhr : r = 0\n⊢ Unitization.inl r = -↑a","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ","nextTactic":"ext","declUpToTactic":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.126_0.vVYVSGoMcyboux2","decl":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"case pos.h1\nF : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : CommRing R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh : ∀ (r : R), r ≠ 0 → (algebraMap R A) r ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nr : R\na : ↥s\nhx : (algebraMap R A) r = -↑a\nhr : r = 0\n⊢ Unitization.fst (Unitization.inl r) = Unitization.fst (-↑a)","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> ","nextTactic":"simp [hr] at hx ⊢","declUpToTactic":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.126_0.vVYVSGoMcyboux2","decl":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"case pos.h2.a\nF : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : CommRing R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh : ∀ (r : R), r ≠ 0 → (algebraMap R A) r ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nr : R\na : ↥s\nhx : (algebraMap R A) r = -↑a\nhr : r = 0\n⊢ ↑(Unitization.snd (Unitization.inl r)) = ↑(Unitization.snd (-↑a))","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> ","nextTactic":"simp [hr] at hx ⊢","declUpToTactic":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.126_0.vVYVSGoMcyboux2","decl":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"case pos.h2.a\nF : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : CommRing R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh : ∀ (r : R), r ≠ 0 → (algebraMap R A) r ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nr : R\na : ↥s\nhr : r = 0\nhx : a = 0\n⊢ a = 0","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n ","nextTactic":"exact hx","declUpToTactic":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.126_0.vVYVSGoMcyboux2","decl":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"case neg\nF : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : CommRing R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh : ∀ (r : R), r ≠ 0 → (algebraMap R A) r ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nr : R\na : ↥s\nhx : (algebraMap R A) r = -↑a\nhr : ¬r = 0\n⊢ Unitization.inl r = -↑a","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · ","nextTactic":"exact (h r hr <| hx ▸ (neg_mem a.property)).elim","declUpToTactic":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.126_0.vVYVSGoMcyboux2","decl":"/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"F : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : Field R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\n⊢ Function.Injective ⇑f","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n ","nextTactic":"refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf","declUpToTactic":"/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.142_0.vVYVSGoMcyboux2","decl":"/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"F : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : Field R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nr : R\nhr : r ≠ 0\nhr' : (algebraMap R A) r ∈ s\n⊢ False","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n ","nextTactic":"rw [Algebra.algebraMap_eq_smul_one] at hr'","declUpToTactic":"/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.142_0.vVYVSGoMcyboux2","decl":"/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"F : Type u_1\nR : Type u_2\nS : Type u_3\nA : Type u_4\ninst✝⁴ : Field R\ninst✝³ : Ring A\ninst✝² : Algebra R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\ninst✝ : AlgHomClass F R (Unitization R ↥s) A\nf : F\nhf : ∀ (x : ↥s), f ↑x = ↑x\nr : R\nhr : r ≠ 0\nhr' : r • 1 ∈ s\n⊢ False","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n ","nextTactic":"exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'","declUpToTactic":"/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.142_0.vVYVSGoMcyboux2","decl":"/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : Field R\ninst✝² : Ring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\nx✝ : ↥s\n⊢ (unitization s) ↑x✝ = ↑x✝","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by ","nextTactic":"simp","declUpToTactic":"theorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.157_0.vVYVSGoMcyboux2","decl":"theorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : Field R\ninst✝² : Ring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\nalgHom : Unitization R ↥s →ₐ[R] ↥(Algebra.adjoin R ↑s) :=\n AlgHom.codRestrict (unitization s) (Algebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ Algebra.adjoin R ↑s)\n⊢ Function.Bijective ⇑algHom","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n ","nextTactic":"refine ⟨?_, fun x ↦ ?_⟩","declUpToTactic":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.160_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) "} +{"state":"case refine_1\nR : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : Field R\ninst✝² : Ring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\nalgHom : Unitization R ↥s →ₐ[R] ↥(Algebra.adjoin R ↑s) :=\n AlgHom.codRestrict (unitization s) (Algebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ Algebra.adjoin R ↑s)\n⊢ Function.Injective ⇑algHom","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · ","nextTactic":"have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp","declUpToTactic":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.160_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : Field R\ninst✝² : Ring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\nalgHom : Unitization R ↥s →ₐ[R] ↥(Algebra.adjoin R ↑s) :=\n AlgHom.codRestrict (unitization s) (Algebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ Algebra.adjoin R ↑s)\nx✝ : ↥s\n⊢ (AlgHom.comp (Subalgebra.val (Algebra.adjoin R ↑s)) algHom) ↑x✝ = ↑x✝","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by ","nextTactic":"simp","declUpToTactic":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.160_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) "} +{"state":"case refine_1\nR : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : Field R\ninst✝² : Ring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\nalgHom : Unitization R ↥s →ₐ[R] ↥(Algebra.adjoin R ↑s) :=\n AlgHom.codRestrict (unitization s) (Algebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ Algebra.adjoin R ↑s)\nthis : Function.Injective ⇑(AlgHom.comp (Subalgebra.val (Algebra.adjoin R ↑s)) algHom)\n⊢ Function.Injective ⇑algHom","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃��ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n ","nextTactic":"rw [AlgHom.coe_comp] at this","declUpToTactic":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.160_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) "} +{"state":"case refine_1\nR : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : Field R\ninst✝² : Ring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\nalgHom : Unitization R ↥s →ₐ[R] ↥(Algebra.adjoin R ↑s) :=\n AlgHom.codRestrict (unitization s) (Algebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ Algebra.adjoin R ↑s)\nthis : Function.Injective (⇑(Subalgebra.val (Algebra.adjoin R ↑s)) ∘ ⇑algHom)\n⊢ Function.Injective ⇑algHom","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n ","nextTactic":"exact this.of_comp","declUpToTactic":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.160_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) "} +{"state":"case refine_2\nR : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : Field R\ninst✝² : Ring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\nalgHom : Unitization R ↥s →ₐ[R] ↥(Algebra.adjoin R ↑s) :=\n AlgHom.codRestrict (unitization s) (Algebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ Algebra.adjoin R ↑s)\nx : ↥(Algebra.adjoin R ↑s)\n⊢ ∃ a, algHom a = x","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · ","nextTactic":"obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property","declUpToTactic":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.160_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) "} +{"state":"case refine_2.intro\nR : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝³ : Field R\ninst✝² : Ring A\ninst✝¹ : Algebra R A\ninst✝ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ns : S\nh1 : 1 ∉ s\nalgHom : Unitization R ↥s →ₐ[R] ↥(Algebra.adjoin R ↑s) :=\n AlgHom.codRestrict (unitization s) (Algebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ Algebra.adjoin R ↑s)\nx : ↥(Algebra.adjoin R ↑s)\na : Unitization R ↥s\nha : ↑(unitization s) a = ↑x\n⊢ ∃ a, algHom a = x","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n ","nextTactic":"exact ⟨a, Subtype.ext ha⟩","declUpToTactic":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.160_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) "} +{"state":"R : Type u_1\ninst✝ : NonAssocSemiring R\nS : Subsemiring R\n⊢ NonUnitalSubsemiring.toSubsemiring (toNonUnitalSubsemiring S) (_ : 1 ∈ S) = S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by ","nextTactic":"cases S","declUpToTactic":"theorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.202_0.vVYVSGoMcyboux2","decl":"theorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S "} +{"state":"case mk\nR : Type u_1\ninst✝ : NonAssocSemiring R\ntoSubmonoid✝ : Submonoid R\nadd_mem'✝ : ∀ {a b : R}, a ∈ toSubmonoid✝.carrier → b ∈ toSubmonoid✝.carrier → a + b ∈ toSubmonoid✝.carrier\nzero_mem'✝ : 0 ∈ toSubmonoid✝.carrier\n⊢ NonUnitalSubsemiring.toSubsemiring\n (toNonUnitalSubsemiring { toSubmonoid := toSubmonoid✝, add_mem' := add_mem'✝, zero_mem' := zero_mem'✝ })\n (_ : 1 ∈ { toSubmonoid := toSubmonoid✝, add_mem' := add_mem'✝, zero_mem' := zero_mem'✝ }) =\n { toSubmonoid := toSubmonoid✝, add_mem' := add_mem'✝, zero_mem' := zero_mem'✝ }","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; ","nextTactic":"rfl","declUpToTactic":"theorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.202_0.vVYVSGoMcyboux2","decl":"theorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S "} +{"state":"R : Type u_1\ninst✝ : NonAssocSemiring R\nS : NonUnitalSubsemiring R\nh1 : 1 ∈ S\n⊢ Subsemiring.toNonUnitalSubsemiring (toSubsemiring S h1) = S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n ","nextTactic":"cases S","declUpToTactic":"theorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.205_0.vVYVSGoMcyboux2","decl":"theorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S "} +{"state":"case mk\nR : Type u_1\ninst✝ : NonAssocSemiring R\ntoAddSubmonoid✝ : AddSubmonoid R\nmul_mem'✝ : ∀ {a b : R}, a ∈ toAddSubmonoid✝.carrier → b ∈ toAddSubmonoid✝.carrier → a * b ∈ toAddSubmonoid✝.carrier\nh1 : 1 ∈ { toAddSubmonoid := toAddSubmonoid✝, mul_mem' := mul_mem'✝ }\n⊢ Subsemiring.toNonUnitalSubsemiring (toSubsemiring { toAddSubmonoid := toAddSubmonoid✝, mul_mem' := mul_mem'✝ } h1) =\n { toAddSubmonoid := toAddSubmonoid✝, mul_mem' := mul_mem'✝ }","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; ","nextTactic":"rfl","declUpToTactic":"theorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.205_0.vVYVSGoMcyboux2","decl":"theorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S "} +{"state":"R : Type u_1\nS : Type u_2\ninst✝¹ : Semiring R\ninst✝ : SetLike S R\nhSR : NonUnitalSubsemiringClass S R\ns : S\n⊢ AlgHom.range (unitization s) = subalgebraOfSubsemiring (Subsemiring.closure ↑s)","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n ","nextTactic":"have := AddSubmonoidClass.nsmulMemClass (S := S)","declUpToTactic":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.224_0.vVYVSGoMcyboux2","decl":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) "} +{"state":"R : Type u_1\nS : Type u_2\ninst✝¹ : Semiring R\ninst✝ : SetLike S R\nhSR : NonUnitalSubsemiringClass S R\ns : S\nthis : SMulMemClass S ℕ R\n⊢ AlgHom.range (unitization s) = subalgebraOfSubsemiring (Subsemiring.closure ↑s)","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n ","nextTactic":"rw [unitization]","declUpToTactic":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.224_0.vVYVSGoMcyboux2","decl":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) "} +{"state":"R : Type u_1\nS : Type u_2\ninst✝¹ : Semiring R\ninst✝ : SetLike S R\nhSR : NonUnitalSubsemiringClass S R\ns : S\nthis : SMulMemClass S ℕ R\n⊢ AlgHom.range (NonUnitalSubalgebra.unitization s) = subalgebraOfSubsemiring (Subsemiring.closure ↑s)","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n ","nextTactic":"rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]","declUpToTactic":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.224_0.vVYVSGoMcyboux2","decl":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) "} +{"state":"R : Type u_1\nS : Type u_2\ninst✝¹ : Semiring R\ninst✝ : SetLike S R\nhSR : NonUnitalSubsemiringClass S R\ns : S\nthis : SMulMemClass S ℕ R\n⊢ Algebra.adjoin ℕ ↑s = subalgebraOfSubsemiring (Subsemiring.closure ↑s)","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n ","nextTactic":"rw [Algebra.adjoin_nat]","declUpToTactic":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.224_0.vVYVSGoMcyboux2","decl":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) "} +{"state":"R : Type u_1\ninst✝ : Ring R\nS : Subring R\n⊢ NonUnitalSubring.toSubring (toNonUnitalSubring S) (_ : 1 ∈ S) = S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by ","nextTactic":"cases S","declUpToTactic":"theorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.252_0.vVYVSGoMcyboux2","decl":"theorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S "} +{"state":"case mk\nR : Type u_1\ninst✝ : Ring R\ntoSubsemiring✝ : Subsemiring R\nneg_mem'✝ : ∀ {x : R}, x ∈ toSubsemiring✝.carrier → -x ∈ toSubsemiring✝.carrier\n⊢ NonUnitalSubring.toSubring (toNonUnitalSubring { toSubsemiring := toSubsemiring✝, neg_mem' := neg_mem'✝ })\n (_ : 1 ∈ { toSubsemiring := toSubsemiring✝, neg_mem' := neg_mem'✝ }) =\n { toSubsemiring := toSubsemiring✝, neg_mem' := neg_mem'✝ }","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; ","nextTactic":"rfl","declUpToTactic":"theorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.252_0.vVYVSGoMcyboux2","decl":"theorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S "} +{"state":"R : Type u_1\ninst✝ : Ring R\nS : NonUnitalSubring R\nh1 : 1 ∈ S\n⊢ Subring.toNonUnitalSubring (toSubring S h1) = S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by ","nextTactic":"cases S","declUpToTactic":"theorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.255_0.vVYVSGoMcyboux2","decl":"theorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S "} +{"state":"case mk\nR : Type u_1\ninst✝ : Ring R\ntoNonUnitalSubsemiring✝ : NonUnitalSubsemiring R\nneg_mem'✝ : ∀ {x : R}, x ∈ toNonUnitalSubsemiring✝.carrier → -x ∈ toNonUnitalSubsemiring✝.carrier\nh1 : 1 ∈ { toNonUnitalSubsemiring := toNonUnitalSubsemiring✝, neg_mem' := neg_mem'✝ }\n⊢ Subring.toNonUnitalSubring\n (toSubring { toNonUnitalSubsemiring := toNonUnitalSubsemiring✝, neg_mem' := neg_mem'✝ } h1) =\n { toNonUnitalSubsemiring := toNonUnitalSubsemiring✝, neg_mem' := neg_mem'✝ }","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; ","nextTactic":"rfl","declUpToTactic":"theorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.255_0.vVYVSGoMcyboux2","decl":"theorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S "} +{"state":"R : Type u_1\nS : Type u_2\ninst✝¹ : Ring R\ninst✝ : SetLike S R\nhSR : NonUnitalSubringClass S R\ns : S\n⊢ AlgHom.range (unitization s) = subalgebraOfSubring (Subring.closure ↑s)","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n ","nextTactic":"have := AddSubgroupClass.zsmulMemClass (S := S)","declUpToTactic":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.273_0.vVYVSGoMcyboux2","decl":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) "} +{"state":"R : Type u_1\nS : Type u_2\ninst✝¹ : Ring R\ninst✝ : SetLike S R\nhSR : NonUnitalSubringClass S R\ns : S\nthis : SMulMemClass S ℤ R\n⊢ AlgHom.range (unitization s) = subalgebraOfSubring (Subring.closure ↑s)","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n ","nextTactic":"rw [unitization]","declUpToTactic":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.273_0.vVYVSGoMcyboux2","decl":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) "} +{"state":"R : Type u_1\nS : Type u_2\ninst✝¹ : Ring R\ninst✝ : SetLike S R\nhSR : NonUnitalSubringClass S R\ns : S\nthis : SMulMemClass S ℤ R\n⊢ AlgHom.range (NonUnitalSubalgebra.unitization s) = subalgebraOfSubring (Subring.closure ↑s)","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n ","nextTactic":"rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]","declUpToTactic":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.273_0.vVYVSGoMcyboux2","decl":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) "} +{"state":"R : Type u_1\nS : Type u_2\ninst✝¹ : Ring R\ninst✝ : SetLike S R\nhSR : NonUnitalSubringClass S R\ns : S\nthis : SMulMemClass S ℤ R\n⊢ Algebra.adjoin ℤ ↑s = subalgebraOfSubring (Subring.closure ↑s)","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n ","nextTactic":"rw [Algebra.adjoin_int]","declUpToTactic":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.273_0.vVYVSGoMcyboux2","decl":"theorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁵ : CommSemiring R\ninst✝⁴ : StarRing R\ninst✝³ : Semiring A\ninst✝² : StarRing A\ninst✝¹ : Algebra R A\ninst✝ : StarModule R A\nS : StarSubalgebra R A\n⊢ NonUnitalStarSubalgebra.toStarSubalgebra (toNonUnitalStarSubalgebra S) (_ : 1 ∈ S.carrier) = S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by ","nextTactic":"cases S","declUpToTactic":"theorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.309_0.vVYVSGoMcyboux2","decl":"theorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S "} +{"state":"case mk\nR : Type u_1\nA : Type u_2\ninst✝⁵ : CommSemiring R\ninst✝⁴ : StarRing R\ninst✝³ : Semiring A\ninst✝² : StarRing A\ninst✝¹ : Algebra R A\ninst✝ : StarModule R A\ntoSubalgebra✝ : Subalgebra R A\nstar_mem'✝ : ∀ {a : A}, a ∈ toSubalgebra✝.carrier → star a ∈ toSubalgebra✝.carrier\n⊢ NonUnitalStarSubalgebra.toStarSubalgebra\n (toNonUnitalStarSubalgebra { toSubalgebra := toSubalgebra✝, star_mem' := star_mem'✝ })\n (_ :\n 1 ∈\n { toSubalgebra := toSubalgebra✝,\n star_mem' := star_mem'✝ }.toSubalgebra.toSubsemiring.toSubmonoid.toSubsemigroup.carrier) =\n { toSubalgebra := toSubalgebra✝, star_mem' := star_mem'✝ }","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; ","nextTactic":"rfl","declUpToTactic":"theorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.309_0.vVYVSGoMcyboux2","decl":"theorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S "} +{"state":"R : Type u_1\nA : Type u_2\ninst✝⁵ : CommSemiring R\ninst✝⁴ : StarRing R\ninst✝³ : Semiring A\ninst✝² : StarRing A\ninst✝¹ : Algebra R A\ninst✝ : StarModule R A\nS : NonUnitalStarSubalgebra R A\nh1 : 1 ∈ S\n⊢ StarSubalgebra.toNonUnitalStarSubalgebra (toStarSubalgebra S h1) = S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n ","nextTactic":"cases S","declUpToTactic":"theorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.312_0.vVYVSGoMcyboux2","decl":"theorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S "} +{"state":"case mk\nR : Type u_1\nA : Type u_2\ninst✝⁵ : CommSemiring R\ninst✝⁴ : StarRing R\ninst✝³ : Semiring A\ninst✝² : StarRing A\ninst✝¹ : Algebra R A\ninst✝ : StarModule R A\ntoNonUnitalSubalgebra✝ : NonUnitalSubalgebra R A\nstar_mem'✝ : ∀ {a : A}, a ∈ toNonUnitalSubalgebra✝.carrier → star a ∈ toNonUnitalSubalgebra✝.carrier\nh1 : 1 ∈ { toNonUnitalSubalgebra := toNonUnitalSubalgebra✝, star_mem' := star_mem'✝ }\n⊢ StarSubalgebra.toNonUnitalStarSubalgebra\n (toStarSubalgebra { toNonUnitalSubalgebra := toNonUnitalSubalgebra✝, star_mem' := star_mem'✝ } h1) =\n { toNonUnitalSubalgebra := toNonUnitalSubalgebra✝, star_mem' := star_mem'✝ }","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[���] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; ","nextTactic":"rfl","declUpToTactic":"theorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.312_0.vVYVSGoMcyboux2","decl":"theorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nS : StarSubalgebra R C\n⊢ StarAlgHom.range (starLift f) ≤ S ↔ NonUnitalStarAlgHom.range f ≤ StarSubalgebra.toNonUnitalStarSubalgebra S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n ","nextTactic":"refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩","declUpToTactic":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.325_0.vVYVSGoMcyboux2","decl":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra "} +{"state":"case refine_1\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nS : StarSubalgebra R C\nh : StarAlgHom.range (starLift f) ≤ S\n⊢ NonUnitalStarAlgHom.range f ≤ StarSubalgebra.toNonUnitalStarSubalgebra S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · ","nextTactic":"rintro - ⟨x, rfl⟩","declUpToTactic":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.325_0.vVYVSGoMcyboux2","decl":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra "} +{"state":"case refine_1.intro\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nS : StarSubalgebra R C\nh : StarAlgHom.range (starLift f) ≤ S\nx : A\n⊢ ↑↑f x ∈ StarSubalgebra.toNonUnitalStarSubalgebra S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n ","nextTactic":"exact @h (f x) ⟨x, by simp⟩","declUpToTactic":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.325_0.vVYVSGoMcyboux2","decl":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nS : StarSubalgebra R C\nh : StarAlgHom.range (starLift f) ≤ S\nx : A\n⊢ ↑(starLift f).toAlgHom ↑x = f x","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by ","nextTactic":"simp","declUpToTactic":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.325_0.vVYVSGoMcyboux2","decl":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra "} +{"state":"case refine_2\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nS : StarSubalgebra R C\nh : NonUnitalStarAlgHom.range f ≤ StarSubalgebra.toNonUnitalStarSubalgebra S\n⊢ StarAlgHom.range (starLift f) ≤ S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · ","nextTactic":"rintro - ⟨x, rfl⟩","declUpToTactic":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.325_0.vVYVSGoMcyboux2","decl":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra "} +{"state":"case refine_2.intro\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nS : StarSubalgebra R C\nh : NonUnitalStarAlgHom.range f ≤ StarSubalgebra.toNonUnitalStarSubalgebra S\nx : Unitization R A\n⊢ ↑(starLift f).toAlgHom x ∈ S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n ","nextTactic":"induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)","declUpToTactic":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.325_0.vVYVSGoMcyboux2","decl":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra "} +{"state":"case refine_2.intro\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nS : StarSubalgebra R C\nh : NonUnitalStarAlgHom.range f ≤ StarSubalgebra.toNonUnitalStarSubalgebra S\nx : Unitization R A\n⊢ ↑(starLift f).toAlgHom x ∈ S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n ","nextTactic":"induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)","declUpToTactic":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.325_0.vVYVSGoMcyboux2","decl":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra "} +{"state":"case refine_2.intro.h\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nS : StarSubalgebra R C\nh : NonUnitalStarAlgHom.range f ≤ StarSubalgebra.toNonUnitalStarSubalgebra S\nr : R\na : A\n⊢ ↑(starLift f).toAlgHom (inl r + ↑a) ∈ S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n ","nextTactic":"| _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)","declUpToTactic":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.325_0.vVYVSGoMcyboux2","decl":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra "} +{"state":"case refine_2.intro.h\nR : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nS : StarSubalgebra R C\nh : NonUnitalStarAlgHom.range f ≤ StarSubalgebra.toNonUnitalStarSubalgebra S\nr : R\na : A\n⊢ ↑(starLift f).toAlgHom (inl r + ↑a) ∈ S","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => ","nextTactic":"simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)","declUpToTactic":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.325_0.vVYVSGoMcyboux2","decl":"theorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nc : StarSubalgebra R C\n⊢ StarAlgHom.range (starLift f) ≤ c ↔ StarSubalgebra.adjoin R ↑(NonUnitalStarAlgHom.range f) ≤ c","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n ","nextTactic":"rw [starLift_range_le]","declUpToTactic":"theorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.335_0.vVYVSGoMcyboux2","decl":"theorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nc : StarSubalgebra R C\n⊢ NonUnitalStarAlgHom.range f ≤ StarSubalgebra.toNonUnitalStarSubalgebra c ↔\n StarSubalgebra.adjoin R ↑(NonUnitalStarAlgHom.range f) ≤ c","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n ","nextTactic":"rw [StarSubalgebra.adjoin_le_iff]","declUpToTactic":"theorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.335_0.vVYVSGoMcyboux2","decl":"theorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) "} +{"state":"R : Type u_1\nA : Type u_2\nC : Type u_3\ninst✝¹¹ : CommSemiring R\ninst✝¹⁰ : NonUnitalSemiring A\ninst✝⁹ : StarRing R\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✝² : StarRing C\ninst✝¹ : Algebra R C\ninst✝ : StarModule R C\nf : A →⋆ₙₐ[R] C\nc : StarSubalgebra R C\n⊢ NonUnitalStarAlgHom.range f ≤ StarSubalgebra.toNonUnitalStarSubalgebra c ↔ ↑(NonUnitalStarAlgHom.range f) ⊆ ↑c","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n ","nextTactic":"rfl","declUpToTactic":"theorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.335_0.vVYVSGoMcyboux2","decl":"theorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : CommSemiring R\ninst✝⁶ : StarRing R\ninst✝⁵ : Semiring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubsemiringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\n⊢ StarAlgHom.range (unitization s) = StarSubalgebra.adjoin R ↑s","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n ","nextTactic":"rw [unitization]","declUpToTactic":"theorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.360_0.vVYVSGoMcyboux2","decl":"theorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : CommSemiring R\ninst✝⁶ : StarRing R\ninst✝⁵ : Semiring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubsemiringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\n⊢ StarAlgHom.range (Unitization.starLift (NonUnitalStarSubalgebraClass.subtype s)) = StarSubalgebra.adjoin R ↑s","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n ","nextTactic":"rw [Unitization.starLift_range]","declUpToTactic":"theorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.360_0.vVYVSGoMcyboux2","decl":"theorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : CommSemiring R\ninst✝⁶ : StarRing R\ninst✝⁵ : Semiring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubsemiringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\n⊢ StarSubalgebra.adjoin R ↑(NonUnitalStarAlgHom.range (NonUnitalStarSubalgebraClass.subtype s)) =\n StarSubalgebra.adjoin R ↑s","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n ","nextTactic":"simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]","declUpToTactic":"theorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.360_0.vVYVSGoMcyboux2","decl":"theorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : CommSemiring R\ninst✝⁶ : StarRing R\ninst✝⁵ : Semiring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubsemiringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\n⊢ StarSubalgebra.adjoin R {x | x ∈ s} = StarSubalgebra.adjoin R ↑s","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]\n ","nextTactic":"rfl","declUpToTactic":"theorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.360_0.vVYVSGoMcyboux2","decl":"theorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : Field R\ninst✝⁶ : StarRing R\ninst✝⁵ : Ring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\nh1 : 1 ∉ s\nx✝ : ↥s\n⊢ (unitization s) ↑x✝ = ↑x✝","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]\n rfl\n\nend Semiring\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [StarRing R] [Ring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by ","nextTactic":"simp","declUpToTactic":"theorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.375_0.vVYVSGoMcyboux2","decl":"theorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : Field R\ninst✝⁶ : StarRing R\ninst✝⁵ : Ring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\nh1 : 1 ∉ s\nstarAlgHom : Unitization R ↥s →⋆ₐ[R] ↥(StarSubalgebra.adjoin R ↑s) :=\n StarAlgHom.codRestrict (unitization s) (StarSubalgebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ StarSubalgebra.adjoin R ↑s)\n⊢ Function.Bijective ⇑starAlgHom","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]\n rfl\n\nend Semiring\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [StarRing R] [Ring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n ","nextTactic":"refine ⟨?_, fun x ↦ ?_⟩","declUpToTactic":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.378_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) "} +{"state":"case refine_1\nR : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : Field R\ninst✝⁶ : StarRing R\ninst✝⁵ : Ring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\nh1 : 1 ∉ s\nstarAlgHom : Unitization R ↥s →⋆ₐ[R] ↥(StarSubalgebra.adjoin R ↑s) :=\n StarAlgHom.codRestrict (unitization s) (StarSubalgebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ StarSubalgebra.adjoin R ↑s)\n⊢ Function.Injective ⇑starAlgHom","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]\n rfl\n\nend Semiring\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [StarRing R] [Ring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · ","nextTactic":"have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by simp","declUpToTactic":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.378_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) "} +{"state":"R : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : Field R\ninst✝⁶ : StarRing R\ninst✝⁵ : Ring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\nh1 : 1 ∉ s\nstarAlgHom : Unitization R ↥s →⋆ₐ[R] ↥(StarSubalgebra.adjoin R ↑s) :=\n StarAlgHom.codRestrict (unitization s) (StarSubalgebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ StarSubalgebra.adjoin R ↑s)\nx✝ : ↥s\n⊢ (StarAlgHom.comp (StarSubalgebra.subtype (StarSubalgebra.adjoin R ↑s)) starAlgHom) ↑x✝ = ↑x✝","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]\n rfl\n\nend Semiring\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [StarRing R] [Ring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by ","nextTactic":"simp","declUpToTactic":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.378_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) "} +{"state":"case refine_1\nR : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : Field R\ninst✝⁶ : StarRing R\ninst✝⁵ : Ring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\nh1 : 1 ∉ s\nstarAlgHom : Unitization R ↥s →⋆ₐ[R] ↥(StarSubalgebra.adjoin R ↑s) :=\n StarAlgHom.codRestrict (unitization s) (StarSubalgebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ StarSubalgebra.adjoin R ↑s)\nthis : Function.Injective ⇑(StarAlgHom.comp (StarSubalgebra.subtype (StarSubalgebra.adjoin R ↑s)) starAlgHom)\n⊢ Function.Injective ⇑starAlgHom","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) �� S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]\n rfl\n\nend Semiring\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [StarRing R] [Ring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by simp\n ","nextTactic":"rw [StarAlgHom.coe_comp] at this","declUpToTactic":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by simp\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.378_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) "} +{"state":"case refine_1\nR : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : Field R\ninst✝⁶ : StarRing R\ninst✝⁵ : Ring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\nh1 : 1 ∉ s\nstarAlgHom : Unitization R ↥s →⋆ₐ[R] ↥(StarSubalgebra.adjoin R ↑s) :=\n StarAlgHom.codRestrict (unitization s) (StarSubalgebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ StarSubalgebra.adjoin R ↑s)\nthis : Function.Injective (⇑(StarSubalgebra.subtype (StarSubalgebra.adjoin R ↑s)) ∘ ⇑starAlgHom)\n⊢ Function.Injective ⇑starAlgHom","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]\n rfl\n\nend Semiring\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [StarRing R] [Ring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by simp\n rw [StarAlgHom.coe_comp] at this\n ","nextTactic":"exact this.of_comp","declUpToTactic":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by simp\n rw [StarAlgHom.coe_comp] at this\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.378_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) "} +{"state":"case refine_2\nR : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : Field R\ninst✝⁶ : StarRing R\ninst✝⁵ : Ring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\nh1 : 1 ∉ s\nstarAlgHom : Unitization R ↥s →⋆ₐ[R] ↥(StarSubalgebra.adjoin R ↑s) :=\n StarAlgHom.codRestrict (unitization s) (StarSubalgebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ StarSubalgebra.adjoin R ↑s)\nx : ↥(StarSubalgebra.adjoin R ↑s)\n⊢ ∃ a, starAlgHom a = x","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]\n rfl\n\nend Semiring\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [StarRing R] [Ring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by simp\n rw [StarAlgHom.coe_comp] at this\n exact this.of_comp\n · ","nextTactic":"obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property","declUpToTactic":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by simp\n rw [StarAlgHom.coe_comp] at this\n exact this.of_comp\n · ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.378_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) "} +{"state":"case refine_2.intro\nR : Type u_1\nS : Type u_2\nA : Type u_3\ninst✝⁷ : Field R\ninst✝⁶ : StarRing R\ninst✝⁵ : Ring A\ninst✝⁴ : StarRing A\ninst✝³ : Algebra R A\ninst✝² : StarModule R A\ninst✝¹ : SetLike S A\nhSA : NonUnitalSubringClass S A\nhSRA : SMulMemClass S R A\ninst✝ : StarMemClass S A\ns : S\nh1 : 1 ∉ s\nstarAlgHom : Unitization R ↥s →⋆ₐ[R] ↥(StarSubalgebra.adjoin R ↑s) :=\n StarAlgHom.codRestrict (unitization s) (StarSubalgebra.adjoin R ↑s)\n (_ : ∀ (x : Unitization R ↥s), (unitization s) x ∈ StarSubalgebra.adjoin R ↑s)\nx : ↥(StarSubalgebra.adjoin R ↑s)\na : Unitization R ↥s\nha : ↑(unitization s).toAlgHom a = ↑x\n⊢ ∃ a, starAlgHom a = x","srcUpToTactic":"/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n\nimport Mathlib.Algebra.Algebra.NonUnitalSubalgebra\nimport Mathlib.Algebra.Star.Subalgebra\nimport Mathlib.Algebra.Algebra.Unitization\nimport Mathlib.Algebra.Star.NonUnitalSubalgebra\n\n/-!\n# Relating unital and non-unital substructures\n\nThis file relates various algebraic structures and provides maps (generally algebra homomorphisms),\nfrom the unitization of a non-unital subobject into the full structure. The range of this map is\nthe unital closure of the non-unital subobject (e.g., `Algebra.adjoin`, `Subring.closure`,\n`Subsemiring.closure` or `StarSubalgebra.adjoin`). When the underlying scalar ring is a field, for\nthis map to be injective it suffices that the range omits `1`. In this setting we provide suitable\n`AlgEquiv` (or `StarAlgEquiv`) onto the range.\n\n## Main declarations\n\n* `NonUnitalSubalgebra.unitization s : Unitization R s →ₐ[R] A`:\n where `s` is a non-unital subalgebra of a unital `R`-algebra `A`, this is the natural algebra\n homomorphism sending `(r, a)` to `r • 1 + a`. The range of this map is\n `Algebra.adjoin R (s : Set A)`.\n* `NonUnitalSubalgebra.unitizationAlgEquiv s : Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A)`\n when `R` is a field and `1 ∉ s`. This is `NonUnitalSubalgebra.unitization` upgraded to an\n `AlgEquiv` onto its range.\n* `NonUnitalSubsemiring.unitization : Unitization ℕ s →ₐ[ℕ] R`: the natural `ℕ`-algebra homomorphism\n from the unitization of a non-unital subsemiring `s` into the ring containing it. The range of\n this map is `subalgebraOfSubsemiring (Subsemiring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalSubring.unitization : Unitization ℤ s →ₐ[ℤ] R`:\n the natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring `s` into the\n ring containing it. The range of this map is `subalgebraOfSubring (Subring.closure s)`.\n This is just `NonUnitalSubalgebra.unitization s` but we provide a separate declaration because\n there is an instance Lean can't find on its own due to `outParam`.\n* `NonUnitalStarSubalgebra s : Unitization R s →⋆ₐ[R] A`: a version of\n `NonUnitalSubalgebra.unitization` for star algebras.\n* `NonUnitalStarSubalgebra.unitizationStarAlgEquiv s :`\n `Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A)`:\n a version of `NonUnitalSubalgebra.unitizationAlgEquiv` for star algebras.\n-/\n\n/-! ## Subalgebras -/\n\nsection Subalgebra\n\nvariable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/\ndef Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=\n { S with\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :\n (1 : A) ∈ S.toNonUnitalSubalgebra :=\n S.one_mem\n\n/-- Turn a non-unital subalgebra containing `1` into a subalgebra. -/\ndef NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :\n Subalgebra R A :=\n { S with\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :\n S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)\n (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by\n cases S; rfl\n\nend Subalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [Semiring C] [Algebra R C]\n\ntheorem lift_range_le {f : A →ₙₐ[R] C} {S : Subalgebra R C} :\n (lift f).range ≤ S ↔ NonUnitalAlgHom.range f ≤ S.toNonUnitalSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem lift_range (f : A →ₙₐ[R] C) :\n (lift f).range = Algebra.adjoin R (NonUnitalAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by rw [lift_range_le, Algebra.adjoin_le_iff]; rfl\n\nend Unitization\n\nnamespace NonUnitalSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [SetLike S A]\n [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\n/-- The natural `R`-algebra homomorphism from the unitization of a non-unital subalgebra into\nthe algebra containing it. -/\ndef unitization : Unitization R s →ₐ[R] A :=\n Unitization.lift (NonUnitalSubalgebraClass.subtype s)\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) :\n unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = Algebra.adjoin R (s : Set A) := by\n rw [unitization]\n rw [Unitization.lift_range]\n simp only [NonUnitalAlgHom.coe_range, NonUnitalSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype, SetLike.mem_coe]\n rfl\n\nend Semiring\n\n/-- A sufficient condition for injectivity of `NonUnitalSubalgebra.unitization` when the scalars\nare a commutative ring. When the scalars are a field, one should use the more natural\n`NonUnitalStarSubalgebra.unitization_injective` whose hypothesis is easier to verify. -/\ntheorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine' (injective_iff_map_eq_zero _).mpr fun x hx => _\n induction' x using Unitization.ind with r a\n simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx\n rw [add_eq_zero_iff_eq_neg] at hx ⊢\n by_cases hr : r = 0\n · ext <;> simp [hr] at hx ⊢\n exact hx\n · exact (h r hr <| hx ▸ (neg_mem a.property)).elim\n\n/-- This is a generic version which allows us to prove both\n`NonUnitalSubalgebra.unitization_injective` and `NonUnitalStarSubalgebra.unitization_injective`. -/\ntheorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A]\n [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n (s : S) (h1 : 1 ∉ s) [AlgHomClass F R (Unitization R s) A] (f : F)\n (hf : ∀ x : s, f x = x) : Function.Injective f := by\n refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf\n rw [Algebra.algebraMap_eq_smul_one] at hr'\n exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [Ring A] [Algebra R A]\n [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `Algebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃ₐ[R] Algebra.adjoin R (s : Set A) :=\n let algHom : Unitization R s →ₐ[R] Algebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| AlgHom.mem_range_self _ x)\n AlgEquiv.ofBijective algHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1\n ((Subalgebra.val _).comp algHom) fun _ ↦ by simp\n rw [AlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n exact ⟨a, Subtype.ext ha⟩\n\nend Field\n\nend NonUnitalSubalgebra\n\n/-! ## Subsemirings -/\n\nsection Subsemiring\n\nvariable {R : Type*} [NonAssocSemiring R]\n\n/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/\ndef Subsemiring.toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R :=\n { S with }\n\ntheorem Subsemiring.one_mem_toNonUnitalSubsemiring (S : Subsemiring R) :\n (1 : R) ∈ S.toNonUnitalSubsemiring :=\n S.one_mem\n\n/-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/\ndef NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : (1 : R) ∈ S) :\n Subsemiring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) :\n S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R)\n (h1 : (1 : R) ∈ S) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := by\n cases S; rfl\n\nend Subsemiring\n\nnamespace NonUnitalSubsemiring\n\nvariable {R S : Type*} [Semiring R] [SetLike S R] [hSR : NonUnitalSubsemiringClass S R] (s : S)\n\n/-- The natural `ℕ`-algebra homomorphism from the unitization of a non-unital subsemiring to\nits `Subsemiring.closure`. -/\ndef unitization : Unitization ℕ s →ₐ[ℕ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubmonoidClass.nsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℕ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubsemiring (Subsemiring.closure s) := by\n have := AddSubmonoidClass.nsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_nat]\n\nend NonUnitalSubsemiring\n\n/-! ## Subrings -/\n\nsection Subring\n\n-- TODO: Maybe we could use `NonAssocRing` here but right now `Subring` takes a `Ring` argument.\nvariable {R : Type*} [Ring R]\n\n/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/\ndef Subring.toNonUnitalSubring (S : Subring R) : NonUnitalSubring R :=\n { S with }\n\ntheorem Subring.one_mem_toNonUnitalSubring (S : Subring R) : (1 : R) ∈ S.toNonUnitalSubring :=\n S.one_mem\n\n/-- Turn a non-unital subring containing `1` into a subring. -/\ndef NonUnitalSubring.toSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) : Subring R :=\n { S with\n one_mem' := h1 }\n\ntheorem Subring.toNonUnitalSubring_toSubring (S : Subring R) :\n S.toNonUnitalSubring.toSubring S.one_mem = S := by cases S; rfl\n\ntheorem NonUnitalSubring.toSubring_toNonUnitalSubring (S : NonUnitalSubring R) (h1 : (1 : R) ∈ S) :\n (NonUnitalSubring.toSubring S h1).toNonUnitalSubring = S := by cases S; rfl\n\nend Subring\n\nnamespace NonUnitalSubring\n\nvariable {R S : Type*} [Ring R] [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)\n\n/-- The natural `ℤ`-algebra homomorphism from the unitization of a non-unital subring to\nits `Subring.closure`. -/\ndef unitization : Unitization ℤ s →ₐ[ℤ] R :=\n NonUnitalSubalgebra.unitization (hSRA := AddSubgroupClass.zsmulMemClass) s\n\n@[simp]\ntheorem unitization_apply (x : Unitization ℤ s) : unitization s x = x.fst + x.snd :=\n rfl\n\ntheorem unitization_range :\n (unitization s).range = subalgebraOfSubring (Subring.closure s) := by\n have := AddSubgroupClass.zsmulMemClass (S := S)\n rw [unitization]\n rw [NonUnitalSubalgebra.unitization_range (hSRA := this)]\n rw [Algebra.adjoin_int]\n\nend NonUnitalSubring\n\n/-! ## Star subalgebras -/\n\nsection StarSubalgebra\n\nvariable {R A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A]\nvariable [Algebra R A] [StarModule R A]\n\n/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/\ndef StarSubalgebra.toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n NonUnitalStarSubalgebra R A :=\n { S with\n carrier := S.carrier\n smul_mem' := fun r _x hx => S.smul_mem hx r }\n\ntheorem StarSubalgebra.one_mem_toNonUnitalStarSubalgebra (S : StarSubalgebra R A) :\n (1 : A) ∈ S.toNonUnitalStarSubalgebra :=\n S.one_mem'\n\n/-- Turn a non-unital star subalgebra containing `1` into a `StarSubalgebra`. -/\ndef NonUnitalStarSubalgebra.toStarSubalgebra (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n StarSubalgebra R A :=\n { S with\n carrier := S.carrier\n one_mem' := h1\n algebraMap_mem' := fun r =>\n (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }\n\ntheorem StarSubalgebra.toNonUnitalStarSubalgebra_toStarSubalgebra (S : StarSubalgebra R A) :\n S.toNonUnitalStarSubalgebra.toStarSubalgebra S.one_mem' = S := by cases S; rfl\n\ntheorem NonUnitalStarSubalgebra.toStarSubalgebra_toNonUnitalStarSubalgebra\n (S : NonUnitalStarSubalgebra R A) (h1 : (1 : A) ∈ S) :\n (S.toStarSubalgebra h1).toNonUnitalStarSubalgebra = S := by\n cases S; rfl\n\nend StarSubalgebra\n\nnamespace Unitization\n\nvariable {R A C : Type*} [CommSemiring R] [NonUnitalSemiring A] [StarRing R] [StarRing A]\nvariable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [StarModule R A]\nvariable [Semiring C] [StarRing C] [Algebra R C] [StarModule R C]\n\ntheorem starLift_range_le\n {f : A →⋆ₙₐ[R] C} {S : StarSubalgebra R C} :\n (starLift f).range ≤ S ↔ NonUnitalStarAlgHom.range f ≤ S.toNonUnitalStarSubalgebra := by\n refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · rintro - ⟨x, rfl⟩\n exact @h (f x) ⟨x, by simp⟩\n · rintro - ⟨x, rfl⟩\n induction x using ind with\n | _ r a => simpa using add_mem (algebraMap_mem S r) (h ⟨a, rfl⟩)\n\ntheorem starLift_range (f : A →⋆ₙₐ[R] C) :\n (starLift f).range = StarSubalgebra.adjoin R (NonUnitalStarAlgHom.range f : Set C) :=\n eq_of_forall_ge_iff fun c ↦ by\n rw [starLift_range_le]\n rw [StarSubalgebra.adjoin_le_iff]\n rfl\n\nend Unitization\n\nnamespace NonUnitalStarSubalgebra\n\nsection Semiring\n\nvariable {R S A : Type*} [CommSemiring R] [StarRing R] [Semiring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubsemiringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n/-- The natural star `R`-algebra homomorphism from the unitization of a non-unital star subalgebra\nto its `StarSubalgebra.adjoin`. -/\ndef unitization : Unitization R s →⋆ₐ[R] A :=\n Unitization.starLift <| NonUnitalStarSubalgebraClass.subtype s\n\n@[simp]\ntheorem unitization_apply (x : Unitization R s) : unitization s x = algebraMap R A x.fst + x.snd :=\n rfl\n\ntheorem unitization_range : (unitization s).range = StarSubalgebra.adjoin R s := by\n rw [unitization]\n rw [Unitization.starLift_range]\n simp only [NonUnitalStarAlgHom.coe_range, NonUnitalStarSubalgebraClass.coeSubtype,\n Subtype.range_coe_subtype]\n rfl\n\nend Semiring\n\nsection Field\n\nvariable {R S A : Type*} [Field R] [StarRing R] [Ring A] [StarRing A] [Algebra R A]\n [StarModule R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A]\n [StarMemClass S A] (s : S)\n\ntheorem unitization_injective (h1 : (1 : A) ∉ s) : Function.Injective (unitization s) :=\n AlgHomClass.unitization_injective s h1 (unitization s) fun _ ↦ by simp\n\n/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by simp\n rw [StarAlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n ","nextTactic":"exact ⟨a, Subtype.ext ha⟩","declUpToTactic":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n let starAlgHom : Unitization R s →⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) :=\n ((unitization s).codRestrict _\n fun x ↦ (unitization_range s).le <| Set.mem_range_self x)\n StarAlgEquiv.ofBijective starAlgHom <| by\n refine ⟨?_, fun x ↦ ?_⟩\n · have := AlgHomClass.unitization_injective s h1 ((StarSubalgebra.subtype _).comp starAlgHom)\n fun _ ↦ by simp\n rw [StarAlgHom.coe_comp] at this\n exact this.of_comp\n · obtain (⟨a, ha⟩ : (x : A) ∈ (unitization s).range) :=\n (unitization_range s).ge x.property\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Subalgebra_Unitization.378_0.vVYVSGoMcyboux2","decl":"/-- If a `NonUnitalStarSubalgebra` over a field does not contain `1`, then its unitization is\nisomorphic to its `StarSubalgebra.adjoin`. -/\n@[simps! apply_coe]\nnoncomputable def unitizationStarAlgEquiv (h1 : (1 : A) ∉ s) :\n Unitization R s ≃⋆ₐ[R] StarSubalgebra.adjoin R (s : Set A) "}