@@ -95,6 +95,28 @@ variables [comm_semiring R] [comm_semiring S] [semiring A] [algebra R A]
95
95
lemma smul_def'' (r : R) (x : A) : r • x = algebra_map R A r * x :=
96
96
algebra.smul_def' r x
97
97
98
+ /--
99
+ To prove two algebra structures on a fixed `[comm_semiring R] [semiring A]` agree,
100
+ it suffices to check the `algebra_map`s agree.
101
+ -/
102
+ -- We'll later use this to show `algebra ℤ M` is a subsingleton.
103
+ @[ext]
104
+ lemma algebra_ext {R : Type *} [comm_semiring R] {A : Type *} [semiring A] (P Q : algebra R A)
105
+ (w : ∀ (r : R), by { haveI := P, exact algebra_map R A r } = by { haveI := Q, exact algebra_map R A r }) :
106
+ P = Q :=
107
+ begin
108
+ unfreezingI { rcases P with ⟨⟨P⟩⟩, rcases Q with ⟨⟨Q⟩⟩ },
109
+ congr,
110
+ { funext r a,
111
+ replace w := congr_arg (λ s, s * a) (w r),
112
+ simp only [←algebra.smul_def''] at w,
113
+ apply w, },
114
+ { ext r,
115
+ exact w r, },
116
+ { apply proof_irrel_heq, },
117
+ { apply proof_irrel_heq, },
118
+ end
119
+
98
120
@[priority 200 ] -- see Note [lower instance priority]
99
121
instance to_semimodule : semimodule R A :=
100
122
{ one_smul := by simp [smul_def''],
@@ -939,6 +961,13 @@ instance algebra_int : algebra ℤ R :=
939
961
smul_def' := λ _ _, gsmul_eq_mul _ _,
940
962
.. int.cast_ring_hom R }
941
963
964
+ /--
965
+ Promote a ring homomorphisms to a `ℤ`-algebra homomorphism.
966
+ -/
967
+ def ring_hom.to_int_alg_hom {R S : Type *} [ring R] [ring S] (f : R →+* S) : R →ₐ[ℤ] S :=
968
+ { commutes' := λ n, by simp,
969
+ .. f }
970
+
942
971
variables {R}
943
972
/-- A subring is a `ℤ`-subalgebra. -/
944
973
def subalgebra_of_subring (S : set R) [is_subring S] : subalgebra ℤ R :=
@@ -953,6 +982,21 @@ def subalgebra_of_subring (S : set R) [is_subring S] : subalgebra ℤ R :=
953
982
(λ i ih, show ((-i - 1 : ℤ) : R) ∈ S, by { rw [int.cast_sub, int.cast_one],
954
983
exact is_add_subgroup.sub_mem S _ _ ih is_submonoid.one_mem }) }
955
984
985
+
986
+ section
987
+ variables {S : Type *} [ring S]
988
+
989
+ instance int_algebra_subsingleton : subsingleton (algebra ℤ S) :=
990
+ ⟨λ P Q, by { ext, simp, }⟩
991
+ end
992
+
993
+ section
994
+ variables {S : Type *} [semiring S]
995
+
996
+ instance nat_algebra_subsingleton : subsingleton (algebra ℕ S) :=
997
+ ⟨λ P Q, by { ext, simp, }⟩
998
+ end
999
+
956
1000
@[simp] lemma mem_subalgebra_of_subring {x : R} {S : set R} [is_subring S] :
957
1001
x ∈ subalgebra_of_subring S ↔ x ∈ S :=
958
1002
iff.rfl
0 commit comments