Skip to content

Commit bc4142f

Browse files
committed
chore: make pseudoparents of algebraic substructures reducible (leanprover-community#36097)
Make functions that take an algebraic substructure and return a sibling class reducible, this matches actual parents and resolves some usage of `set_option backward.isDefEq.respectTransparency false`. For example it ensures that the field instance on `IntermediateField` has a compatible `Semiring` instance to the one from it extending a `Subalgebra`. Also remove @[simp] from `adjoin_toSubsemiring`, since it prevents other simp lemmas on `adjoin` from applying. Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
1 parent 5308bb7 commit bc4142f

8 files changed

Lines changed: 12 additions & 11 deletions

File tree

Mathlib/Algebra/Algebra/NonUnitalSubalgebra.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ instance instNonUnitalSubringClass : NonUnitalSubringClass (NonUnitalSubalgebra
178178
neg_mem {_ x} hx := neg_one_smul R x ▸ SMulMemClass.smul_mem _ hx }
179179

180180
/-- A non-unital subalgebra over a ring is also a `Subring`. -/
181+
@[reducible]
181182
def toNonUnitalSubring (S : NonUnitalSubalgebra R A) : NonUnitalSubring A where
182183
toNonUnitalSubsemiring := S.toNonUnitalSubsemiring
183184
neg_mem' := neg_mem (s := S)
184185

185-
@[simp]
186186
theorem mem_toNonUnitalSubring {S : NonUnitalSubalgebra R A} {x} :
187187
x ∈ S.toNonUnitalSubring ↔ x ∈ S :=
188188
Iff.rfl

Mathlib/Algebra/Algebra/Subalgebra/Basic.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ protected theorem prod_mem {R : Type u} {A : Type v} [CommSemiring R] [CommSemir
192192
prod_mem h
193193

194194
/-- Turn a `Subalgebra` into a `NonUnitalSubalgebra` by forgetting that it contains `1`. -/
195+
@[reducible]
195196
def toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A where
196197
__ := S
197198
smul_mem' r _x hx := S.smul_mem hx r
@@ -208,7 +209,6 @@ lemma toNonUnitalSubalgebra_injective : Function.Injective
208209
(toNonUnitalSubalgebra : Subalgebra R A → NonUnitalSubalgebra R A) :=
209210
fun _ _ ↦ by simp [SetLike.ext_iff]
210211

211-
@[simp]
212212
lemma toNonUnitalSubalgebra_inj {S U : Subalgebra R A} :
213213
S.toNonUnitalSubalgebra = U.toNonUnitalSubalgebra ↔ S = U :=
214214
toNonUnitalSubalgebra_injective.eq_iff
@@ -234,7 +234,7 @@ protected theorem intCast_mem {R : Type u} {A : Type v} [CommRing R] [Ring A] [A
234234
intCast_mem S n
235235

236236
/-- The projection from a subalgebra of `A` to an additive submonoid of `A`. -/
237-
@[simps coe]
237+
@[reducible]
238238
def toAddSubmonoid {R : Type u} {A : Type v} [CommSemiring R] [Semiring A] [Algebra R A]
239239
(S : Subalgebra R A) : AddSubmonoid A :=
240240
S.toSubsemiring.toAddSubmonoid
@@ -316,13 +316,13 @@ section
316316

317317
instance (priority := low) module' [Semiring R'] [SMul R' R] [Module R' A] [IsScalarTower R' R A] :
318318
Module R' S :=
319-
S.toSubmodule.module'
319+
inferInstance
320320

321321
instance : Module R S :=
322-
S.module'
322+
inferInstance
323323

324324
instance [Semiring R'] [SMul R' R] [Module R' A] [IsScalarTower R' R A] : IsScalarTower R' R S :=
325-
inferInstanceAs (IsScalarTower R' R (toSubmodule S))
325+
inferInstance
326326

327327
/- More general form of `Subalgebra.algebra`.
328328

Mathlib/Algebra/Field/Subfield/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ add_decl_doc Subfield.toSubring
141141
namespace Subfield
142142

143143
/-- The underlying `AddSubgroup` of a subfield. -/
144+
@[reducible]
144145
def toAddSubgroup (s : Subfield K) : AddSubgroup K :=
145146
{ s.toSubring.toAddSubgroup with }
146147

@@ -345,7 +346,6 @@ theorem mem_toSubmonoid {s : Subfield K} {x : K} : x ∈ s.toSubmonoid ↔ x ∈
345346
theorem coe_toSubmonoid : (s.toSubmonoid : Set K) = s :=
346347
rfl
347348

348-
@[simp]
349349
theorem mem_toAddSubgroup {s : Subfield K} {x : K} : x ∈ s.toAddSubgroup ↔ x ∈ s :=
350350
Iff.rfl
351351

Mathlib/Algebra/Ring/Subring/Defs.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ instance : SubringClass (Subring R) R where
222222
neg_mem {s} := s.neg_mem'
223223

224224
/-- Turn a `Subring` into a `NonUnitalSubring` by forgetting that it contains `1`. -/
225+
@[reducible]
225226
def toNonUnitalSubring (S : Subring R) : NonUnitalSubring R where __ := S
226227

227228
@[simp]

Mathlib/Algebra/Ring/Subsemiring/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ instance : SubsemiringClass (Subsemiring R) R where
174174
mul_mem {s} := Subsemigroup.mul_mem' s.toSubmonoid.toSubsemigroup
175175

176176
/-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/
177+
@[reducible]
177178
def toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R where __ := S
178179

179180
@[simp]
@@ -224,7 +225,6 @@ lemma toNonUnitalSubsemiring_injective :
224225
fun S₁ S₂ h => SetLike.ext'_iff.2
225226
(show (S₁.toNonUnitalSubsemiring : Set R) = S₂ from SetLike.ext'_iff.1 h)
226227

227-
@[simp]
228228
lemma toNonUnitalSubsemiring_inj {S₁ S₂ : Subsemiring R} :
229229
S₁.toNonUnitalSubsemiring = S₂.toNonUnitalSubsemiring ↔ S₁ = S₂ :=
230230
toNonUnitalSubsemiring_injective.eq_iff

Mathlib/Algebra/Star/NonUnitalSubalgebra.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ theorem copy_eq (S : NonUnitalStarSubalgebra R A) (s : Set A) (hs : s = ↑S) :
215215
variable (S : NonUnitalStarSubalgebra R A)
216216

217217
/-- A non-unital star subalgebra over a ring is also a `Subring`. -/
218+
@[reducible]
218219
def toNonUnitalSubring {R : Type u} {A : Type v} [CommRing R] [NonUnitalRing A] [Module R A]
219220
[Star A] (S : NonUnitalStarSubalgebra R A) : NonUnitalSubring A where
220221
toNonUnitalSubsemiring := S.toNonUnitalSubsemiring
221222
neg_mem' := neg_mem (s := S)
222223

223-
@[simp]
224224
theorem mem_toNonUnitalSubring {R : Type u} {A : Type v} [CommRing R] [NonUnitalRing A] [Module R A]
225225
[Star A] {S : NonUnitalStarSubalgebra R A} {x} : x ∈ S.toNonUnitalSubring ↔ x ∈ S :=
226226
Iff.rfl

Mathlib/Algebra/Star/Subalgebra.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ instance starModule (s : StarSubalgebra R A) : StarModule R s where
104104
star_smul r a := Subtype.ext (star_smul r (a : A))
105105

106106
/-- Turn a `StarSubalgebra` into a `NonUnitalStarSubalgebra` by forgetting that it contains `1`. -/
107+
@[reducible]
107108
def toNonUnitalStarSubalgebra (S : StarSubalgebra R A) : NonUnitalStarSubalgebra R A where
108109
__ := S
109110
smul_mem' r _x hx := S.smul_mem hx r
@@ -120,7 +121,6 @@ lemma toNonUnitalStarSubalgebra_injective : Function.Injective
120121
(toNonUnitalStarSubalgebra : StarSubalgebra R A → NonUnitalStarSubalgebra R A) :=
121122
fun _ _ ↦ by simp [SetLike.ext_iff]
122123

123-
@[simp]
124124
lemma toNonUnitalStarSubalgebra_inj {S U : StarSubalgebra R A} :
125125
S.toNonUnitalStarSubalgebra = U.toNonUnitalStarSubalgebra ↔ S = U :=
126126
toNonUnitalStarSubalgebra_injective.eq_iff

Mathlib/RingTheory/NonUnitalSubring/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ add_decl_doc NonUnitalSubring.toAddSubgroup
129129
namespace NonUnitalSubring
130130

131131
/-- The underlying submonoid of a `NonUnitalSubring`. -/
132+
@[reducible]
132133
def toSubsemigroup (s : NonUnitalSubring R) : Subsemigroup R :=
133134
{ s.toNonUnitalSubsemiring.toSubsemigroup with carrier := s.carrier }
134135

@@ -329,7 +330,6 @@ instance toNonUnitalCommRing {R} [NonUnitalCommRing R] (s : NonUnitalSubring R)
329330
/-! ## Partial order -/
330331

331332

332-
@[simp]
333333
theorem mem_toSubsemigroup {s : NonUnitalSubring R} {x : R} : x ∈ s.toSubsemigroup ↔ x ∈ s :=
334334
Iff.rfl
335335

0 commit comments

Comments
 (0)