Skip to content

Commit

Permalink
chore: backports of adaptations for leanprover/lean4#6024 (#18896)
Browse files Browse the repository at this point in the history
leanprover/lean4#6024 fixes a serious elaboration bug which, perversely, was quite helpful.

Kyle is investigating replacing the bug with something intentional, but we definitively need to fix the bug in the meantime.

This is the backport of changes from lean-pr-testing-6024 which do not have conflicts with `master`. There are a few more changes that we'll need to handle separately later.

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
  • Loading branch information
2 people authored and TobiasLeichtfried committed Nov 21, 2024
1 parent 93651e9 commit 7aa6a93
Show file tree
Hide file tree
Showing 93 changed files with 293 additions and 220 deletions.
4 changes: 2 additions & 2 deletions Mathlib/Algebra/Algebra/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ variable {R M}
theorem End_algebraMap_isUnit_inv_apply_eq_iff {x : R}
(h : IsUnit (algebraMap R (Module.End S M) x)) (m m' : M) :
(↑(h.unit⁻¹) : Module.End S M) m = m' ↔ m = x • m' :=
{ mp := fun H => ((congr_arg h.unit H).symm.trans (End_isUnit_apply_inv_apply_of_isUnit h _)).symm
{ mp := fun H => H ▸ (End_isUnit_apply_inv_apply_of_isUnit h m).symm
mpr := fun H =>
H.symm ▸ by
apply_fun ⇑h.unit.val using ((Module.End_isUnit_iff _).mp h).injective
Expand All @@ -191,7 +191,7 @@ theorem End_algebraMap_isUnit_inv_apply_eq_iff {x : R}
theorem End_algebraMap_isUnit_inv_apply_eq_iff' {x : R}
(h : IsUnit (algebraMap R (Module.End S M) x)) (m m' : M) :
m' = (↑h.unit⁻¹ : Module.End S M) m ↔ m = x • m' :=
{ mp := fun H => ((congr_arg h.unit H).trans (End_isUnit_apply_inv_apply_of_isUnit h _)).symm
{ mp := fun H => H ▸ (End_isUnit_apply_inv_apply_of_isUnit h m).symm
mpr := fun H =>
H.symm ▸ by
apply_fun (↑h.unit : M → M) using ((Module.End_isUnit_iff _).mp h).injective
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Algebra/NonUnitalSubalgebra.lean
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ noncomputable def iSupLift [Nonempty ι] (K : ι → NonUnitalSubalgebra R A) (d
simp only
rw [hf i k hik, hf j k hjk]
rfl)
(↑(iSup K)) (by rw [coe_iSup_of_directed dir])
_ (by rw [coe_iSup_of_directed dir])
map_zero' := by
dsimp
exact Set.iUnionLift_const _ (fun i : ι => (0 : K i)) (fun _ => rfl) _ (by simp)
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Algebra/Subalgebra/Directed.lean
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ noncomputable def iSupLift (dir : Directed (· ≤ ·) K) (f : ∀ i, K i →ₐ
dsimp
rw [hf i k hik, hf j k hjk]
rfl)
T (by rw [hT, coe_iSup_of_directed dir])
(T : Set A) (by rw [hT, coe_iSup_of_directed dir])
map_one' := by apply Set.iUnionLift_const _ (fun _ => 1) <;> simp
map_zero' := by dsimp; apply Set.iUnionLift_const _ (fun _ => 0) <;> simp
map_mul' := by
Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/Category/BialgebraCat/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variable (R)
@[simps]
def of (X : Type v) [Ring X] [Bialgebra R X] :
BialgebraCat R where
α := X
instBialgebra := (inferInstance : Bialgebra R X)

variable {R}
Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/Category/HopfAlgebraCat/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ variable (R)
@[simps]
def of (X : Type v) [Ring X] [HopfAlgebra R X] :
HopfAlgebraCat R where
α := X
instHopfAlgebra := (inferInstance : HopfAlgebra R X)

variable {R}
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Group/Subgroup/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ theorem map_normalClosure (s : Set G) (f : G →* N) (hf : Surjective f) :
theorem comap_normalClosure (s : Set N) (f : G ≃* N) :
normalClosure (f ⁻¹' s) = (normalClosure s).comap f := by
have := Set.preimage_equiv_eq_image_symm s f.toEquiv
simp_all [comap_equiv_eq_map_symm, map_normalClosure s f.symm f.symm.surjective]
simp_all [comap_equiv_eq_map_symm, map_normalClosure s (f.symm : N →* G) f.symm.surjective]

lemma Normal.of_map_injective {G H : Type*} [Group G] [Group H] {φ : G →* H}
(hφ : Function.Injective φ) {L : Subgroup G} (n : (L.map φ).Normal) : L.Normal :=
Expand Down
12 changes: 6 additions & 6 deletions Mathlib/Algebra/Group/Submonoid/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -354,21 +354,21 @@ theorem mk_pow {M} [Monoid M] {A : Type*} [SetLike A M] [SubmonoidClass A M] {S
"An `AddSubmonoid` of a unital additive magma inherits a unital additive magma structure."]
instance (priority := 75) toMulOneClass {M : Type*} [MulOneClass M] {A : Type*} [SetLike A M]
[SubmonoidClass A M] (S : A) : MulOneClass S :=
Subtype.coe_injective.mulOneClass (↑) rfl (fun _ _ => rfl)
Subtype.coe_injective.mulOneClass Subtype.val rfl (fun _ _ => rfl)

-- Prefer subclasses of `Monoid` over subclasses of `SubmonoidClass`.
/-- A submonoid of a monoid inherits a monoid structure. -/
@[to_additive "An `AddSubmonoid` of an `AddMonoid` inherits an `AddMonoid` structure."]
instance (priority := 75) toMonoid {M : Type*} [Monoid M] {A : Type*} [SetLike A M]
[SubmonoidClass A M] (S : A) : Monoid S :=
Subtype.coe_injective.monoid (↑) rfl (fun _ _ => rfl) (fun _ _ => rfl)
Subtype.coe_injective.monoid Subtype.val rfl (fun _ _ => rfl) (fun _ _ => rfl)

-- Prefer subclasses of `Monoid` over subclasses of `SubmonoidClass`.
/-- A submonoid of a `CommMonoid` is a `CommMonoid`. -/
@[to_additive "An `AddSubmonoid` of an `AddCommMonoid` is an `AddCommMonoid`."]
instance (priority := 75) toCommMonoid {M} [CommMonoid M] {A : Type*} [SetLike A M]
[SubmonoidClass A M] (S : A) : CommMonoid S :=
Subtype.coe_injective.commMonoid (↑) rfl (fun _ _ => rfl) fun _ _ => rfl
Subtype.coe_injective.commMonoid Subtype.val rfl (fun _ _ => rfl) fun _ _ => rfl

/-- The natural monoid hom from a submonoid of monoid `M` to `M`. -/
@[to_additive "The natural monoid hom from an `AddSubmonoid` of `AddMonoid` `M` to `M`."]
Expand Down Expand Up @@ -423,7 +423,7 @@ theorem one_def : (1 : S) = ⟨1, S.one_mem⟩ :=
@[to_additive
"An `AddSubmonoid` of a unital additive magma inherits a unital additive magma structure."]
instance toMulOneClass {M : Type*} [MulOneClass M] (S : Submonoid M) : MulOneClass S :=
Subtype.coe_injective.mulOneClass (↑) rfl fun _ _ => rfl
Subtype.coe_injective.mulOneClass Subtype.val rfl fun _ _ => rfl

@[to_additive]
protected theorem pow_mem {M : Type*} [Monoid M] (S : Submonoid M) {x : M} (hx : x ∈ S) (n : ℕ) :
Expand All @@ -433,12 +433,12 @@ protected theorem pow_mem {M : Type*} [Monoid M] (S : Submonoid M) {x : M} (hx :
/-- A submonoid of a monoid inherits a monoid structure. -/
@[to_additive "An `AddSubmonoid` of an `AddMonoid` inherits an `AddMonoid` structure."]
instance toMonoid {M : Type*} [Monoid M] (S : Submonoid M) : Monoid S :=
Subtype.coe_injective.monoid (↑) rfl (fun _ _ => rfl) fun _ _ => rfl
Subtype.coe_injective.monoid Subtype.val rfl (fun _ _ => rfl) fun _ _ => rfl

/-- A submonoid of a `CommMonoid` is a `CommMonoid`. -/
@[to_additive "An `AddSubmonoid` of an `AddCommMonoid` is an `AddCommMonoid`."]
instance toCommMonoid {M} [CommMonoid M] (S : Submonoid M) : CommMonoid S :=
Subtype.coe_injective.commMonoid (↑) rfl (fun _ _ => rfl) fun _ _ => rfl
Subtype.coe_injective.commMonoid Subtype.val rfl (fun _ _ => rfl) fun _ _ => rfl

/-- The natural monoid hom from a submonoid of monoid `M` to `M`. -/
@[to_additive "The natural monoid hom from an `AddSubmonoid` of `AddMonoid` `M` to `M`."]
Expand Down
6 changes: 3 additions & 3 deletions Mathlib/Algebra/GroupWithZero/Pointwise/Finset.lean
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ variable {α β : Type*} [DecidableEq β]
/-- If scalar multiplication by elements of `α` sends `(0 : β)` to zero,
then the same is true for `(0 : Finset β)`. -/
protected def smulZeroClass [Zero β] [SMulZeroClass α β] : SMulZeroClass α (Finset β) :=
coe_injective.smulZeroClass ⟨(↑), coe_zero⟩ coe_smul_finset
coe_injective.smulZeroClass ⟨toSet, coe_zero⟩ coe_smul_finset

/-- If the scalar multiplication `(· • ·) : α → β → β` is distributive,
then so is `(· • ·) : α → Finset β → Finset β`. -/
Expand All @@ -44,7 +44,7 @@ scoped[Pointwise] attribute [instance] Finset.smulZeroClass Finset.distribSMul
Finset.distribMulAction Finset.mulDistribMulAction

instance [DecidableEq α] [Zero α] [Mul α] [NoZeroDivisors α] : NoZeroDivisors (Finset α) :=
Function.Injective.noZeroDivisors (↑) coe_injective coe_zero coe_mul
Function.Injective.noZeroDivisors toSet coe_injective coe_zero coe_mul

instance noZeroSMulDivisors [Zero α] [Zero β] [SMul α β] [NoZeroSMulDivisors α β] :
NoZeroSMulDivisors (Finset α) (Finset β) where
Expand All @@ -53,7 +53,7 @@ instance noZeroSMulDivisors [Zero α] [Zero β] [SMul α β] [NoZeroSMulDivisors

instance noZeroSMulDivisors_finset [Zero α] [Zero β] [SMul α β] [NoZeroSMulDivisors α β] :
NoZeroSMulDivisors α (Finset β) :=
Function.Injective.noZeroSMulDivisors (↑) coe_injective coe_zero coe_smul_finset
Function.Injective.noZeroSMulDivisors toSet coe_injective coe_zero coe_smul_finset

section SMulZeroClass
variable [Zero β] [SMulZeroClass α β] {s : Finset α} {t : Finset β} {a : α}
Expand Down
4 changes: 2 additions & 2 deletions Mathlib/Algebra/Lie/Semisimple/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ lemma finitelyAtomistic : ∀ s : Finset (LieIdeal R L), ↑s ⊆ {I : LieIdeal
intro s hs I hI
let S := {I : LieIdeal R L | IsAtom I}
obtain rfl | hI := hI.eq_or_lt
· exact ⟨s, le_rfl, rfl⟩
· exact ⟨s, Finset.Subset.rfl, rfl⟩
-- We assume that `I` is strictly smaller than the supremum of `s`.
-- Hence there must exist an atom `J` that is not contained in `I`.
obtain ⟨J, hJs, hJI⟩ : ∃ J ∈ s, ¬ J ≤ I := by
Expand All @@ -212,7 +212,7 @@ lemma finitelyAtomistic : ∀ s : Finset (LieIdeal R L), ↑s ⊆ {I : LieIdeal
set K := s'.sup id
suffices I ≤ K by
obtain ⟨t, hts', htI⟩ := finitelyAtomistic s' hs'S I this
exact ⟨t, le_trans hts' hs'.subset, htI⟩
exact ⟨t, hts'.trans hs'.subset, htI⟩
-- Since `I` is contained in the supremum of `J` with the supremum of `s'`,
-- any element `x` of `I` can be written as `y + z` for some `y ∈ J` and `z ∈ K`.
intro x hx
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Module/FinitePresentation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ lemma Module.finitePresentation_of_ker [Module.FinitePresentation R N]
Submodule.comap_mono (f := π) (bot_le (a := LinearMap.ker l))
rw [← inf_eq_right.mpr this, ← Submodule.range_subtype (LinearMap.ker _),
← Submodule.map_comap_eq, ← LinearMap.ker_comp, e, LinearMap.ker_comp f,
LinearMap.ker_eq_bot.mpr (Submodule.injective_subtype _), Submodule.comap_bot]
LinearMap.ker_eq_bot.mpr (Submodule.injective_subtype (LinearMap.ker l)), Submodule.comap_bot]
exact (Module.FinitePresentation.fg_ker f hf).map (Submodule.subtype _)

end Ring
Expand Down
4 changes: 2 additions & 2 deletions Mathlib/Algebra/Order/Field/Subfield.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ variable {K S : Type*} [SetLike S K]
/-- A subfield of a `LinearOrderedField` is a `LinearOrderedField`. -/
instance (priority := 75) toLinearOrderedField [LinearOrderedField K]
[SubfieldClass S K] (s : S) : LinearOrderedField s :=
Subtype.coe_injective.linearOrderedField (↑) rfl rfl (fun _ _ => rfl)
Subtype.coe_injective.linearOrderedField Subtype.val rfl rfl (fun _ _ => rfl)
(fun _ _ => rfl)
(fun _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (by intros; rfl)
Expand All @@ -31,7 +31,7 @@ variable {K : Type*}

/-- A subfield of a `LinearOrderedField` is a `LinearOrderedField`. -/
instance toLinearOrderedField [LinearOrderedField K] (s : Subfield K) : LinearOrderedField s :=
Subtype.coe_injective.linearOrderedField (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
Subtype.coe_injective.linearOrderedField Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (by intros; rfl)
(fun _ => rfl) (fun _ => rfl) (fun _ => rfl) (by intros; rfl) (fun _ _ => rfl) fun _ _ => rfl
Expand Down
20 changes: 10 additions & 10 deletions Mathlib/Algebra/Order/Monoid/Submonoid.lean
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ variable {M S : Type*} [SetLike S M]
@[to_additive "An `AddSubmonoid` of an `OrderedAddCommMonoid` is an `OrderedAddCommMonoid`."]
instance (priority := 75) toOrderedCommMonoid [OrderedCommMonoid M]
[SubmonoidClass S M] (s : S) : OrderedCommMonoid s :=
Subtype.coe_injective.orderedCommMonoid (↑) rfl (fun _ _ => rfl) fun _ _ => rfl
Subtype.coe_injective.orderedCommMonoid Subtype.val rfl (fun _ _ => rfl) fun _ _ => rfl

-- Prefer subclasses of `Monoid` over subclasses of `SubmonoidClass`.
/-- A submonoid of a `LinearOrderedCommMonoid` is a `LinearOrderedCommMonoid`. -/
@[to_additive
"An `AddSubmonoid` of a `LinearOrderedAddCommMonoid` is a `LinearOrderedAddCommMonoid`."]
instance (priority := 75) toLinearOrderedCommMonoid [LinearOrderedCommMonoid M]
[SubmonoidClass S M] (s : S) : LinearOrderedCommMonoid s :=
Subtype.coe_injective.linearOrderedCommMonoid (↑) rfl (fun _ _ => rfl) (fun _ _ => rfl)
Subtype.coe_injective.linearOrderedCommMonoid Subtype.val rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) fun _ _ => rfl

-- Prefer subclasses of `Monoid` over subclasses of `SubmonoidClass`.
Expand All @@ -38,7 +38,7 @@ instance (priority := 75) toLinearOrderedCommMonoid [LinearOrderedCommMonoid M]
"An `AddSubmonoid` of an `OrderedCancelAddCommMonoid` is an `OrderedCancelAddCommMonoid`."]
instance (priority := 75) toOrderedCancelCommMonoid [OrderedCancelCommMonoid M]
[SubmonoidClass S M] (s : S) : OrderedCancelCommMonoid s :=
Subtype.coe_injective.orderedCancelCommMonoid (↑) rfl (fun _ _ => rfl) fun _ _ => rfl
Subtype.coe_injective.orderedCancelCommMonoid Subtype.val rfl (fun _ _ => rfl) fun _ _ => rfl

-- Prefer subclasses of `Monoid` over subclasses of `SubmonoidClass`.
/-- A submonoid of a `LinearOrderedCancelCommMonoid` is a `LinearOrderedCancelCommMonoid`.
Expand All @@ -48,8 +48,8 @@ instance (priority := 75) toOrderedCancelCommMonoid [OrderedCancelCommMonoid M]
a `LinearOrderedCancelAddCommMonoid`."]
instance (priority := 75) toLinearOrderedCancelCommMonoid [LinearOrderedCancelCommMonoid M]
[SubmonoidClass S M] (s : S) : LinearOrderedCancelCommMonoid s :=
Subtype.coe_injective.linearOrderedCancelCommMonoid (↑) rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) fun _ _ => rfl
Subtype.coe_injective.linearOrderedCancelCommMonoid Subtype.val rfl (fun _ _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl


end SubmonoidClass
Expand All @@ -60,22 +60,22 @@ variable {M : Type*}
/-- A submonoid of an `OrderedCommMonoid` is an `OrderedCommMonoid`. -/
@[to_additive "An `AddSubmonoid` of an `OrderedAddCommMonoid` is an `OrderedAddCommMonoid`."]
instance toOrderedCommMonoid [OrderedCommMonoid M] (S : Submonoid M) : OrderedCommMonoid S :=
Subtype.coe_injective.orderedCommMonoid (↑) rfl (fun _ _ => rfl) fun _ _ => rfl
Subtype.coe_injective.orderedCommMonoid Subtype.val rfl (fun _ _ => rfl) fun _ _ => rfl

/-- A submonoid of a `LinearOrderedCommMonoid` is a `LinearOrderedCommMonoid`. -/
@[to_additive
"An `AddSubmonoid` of a `LinearOrderedAddCommMonoid` is a `LinearOrderedAddCommMonoid`."]
instance toLinearOrderedCommMonoid [LinearOrderedCommMonoid M] (S : Submonoid M) :
LinearOrderedCommMonoid S :=
Subtype.coe_injective.linearOrderedCommMonoid (↑) rfl (fun _ _ => rfl) (fun _ _ => rfl)
Subtype.coe_injective.linearOrderedCommMonoid Subtype.val rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) fun _ _ => rfl

/-- A submonoid of an `OrderedCancelCommMonoid` is an `OrderedCancelCommMonoid`. -/
@[to_additive AddSubmonoid.toOrderedCancelAddCommMonoid
"An `AddSubmonoid` of an `OrderedCancelAddCommMonoid` is an `OrderedCancelAddCommMonoid`."]
instance toOrderedCancelCommMonoid [OrderedCancelCommMonoid M] (S : Submonoid M) :
OrderedCancelCommMonoid S :=
Subtype.coe_injective.orderedCancelCommMonoid (↑) rfl (fun _ _ => rfl) fun _ _ => rfl
Subtype.coe_injective.orderedCancelCommMonoid Subtype.val rfl (fun _ _ => rfl) fun _ _ => rfl

/-- A submonoid of a `LinearOrderedCancelCommMonoid` is a `LinearOrderedCancelCommMonoid`.
-/
Expand All @@ -84,8 +84,8 @@ instance toOrderedCancelCommMonoid [OrderedCancelCommMonoid M] (S : Submonoid M)
a `LinearOrderedCancelAddCommMonoid`."]
instance toLinearOrderedCancelCommMonoid [LinearOrderedCancelCommMonoid M] (S : Submonoid M) :
LinearOrderedCancelCommMonoid S :=
Subtype.coe_injective.linearOrderedCancelCommMonoid (↑) rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) fun _ _ => rfl
Subtype.coe_injective.linearOrderedCancelCommMonoid Subtype.val rfl (fun _ _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl

section Preorder
variable (M)
Expand Down
14 changes: 8 additions & 6 deletions Mathlib/Algebra/Ring/Subring/Order.lean
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,31 @@ variable {R S : Type*} [SetLike S R] (s : S)
/-- A subring of an `OrderedRing` is an `OrderedRing`. -/
instance (priority := 75) toOrderedRing [OrderedRing R] [SubringClass S R] :
OrderedRing s :=
Subtype.coe_injective.orderedRing (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) fun _ => rfl
Subtype.coe_injective.orderedRing Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ => rfl) fun _ => rfl

-- Prefer subclasses of `Ring` over subclasses of `SubringClass`.
/-- A subring of an `OrderedCommRing` is an `OrderedCommRing`. -/
instance (priority := 75) toOrderedCommRing [OrderedCommRing R] [SubringClass S R] :
OrderedCommRing s :=
Subtype.coe_injective.orderedCommRing (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) fun _ => rfl
Subtype.coe_injective.orderedCommRing Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ => rfl) fun _ => rfl

-- Prefer subclasses of `Ring` over subclasses of `SubringClass`.
/-- A subring of a `LinearOrderedRing` is a `LinearOrderedRing`. -/
instance (priority := 75) toLinearOrderedRing [LinearOrderedRing R] [SubringClass S R] :
LinearOrderedRing s :=
Subtype.coe_injective.linearOrderedRing (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
Subtype.coe_injective.linearOrderedRing Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl

-- Prefer subclasses of `Ring` over subclasses of `SubringClass`.
/-- A subring of a `LinearOrderedCommRing` is a `LinearOrderedCommRing`. -/
instance (priority := 75) toLinearOrderedCommRing [LinearOrderedCommRing R] [SubringClass S R] :
LinearOrderedCommRing s :=
Subtype.coe_injective.linearOrderedCommRing (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
Subtype.coe_injective.linearOrderedCommRing Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl

Expand Down
10 changes: 5 additions & 5 deletions Mathlib/Algebra/Ring/Subsemiring/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace SubsemiringClass
-- Prefer subclasses of `NonAssocSemiring` over subclasses of `SubsemiringClass`.
/-- A subsemiring of a `NonAssocSemiring` inherits a `NonAssocSemiring` structure -/
instance (priority := 75) toNonAssocSemiring : NonAssocSemiring s :=
Subtype.coe_injective.nonAssocSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
Subtype.coe_injective.nonAssocSemiring Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) fun _ => rfl

instance nontrivial [Nontrivial R] : Nontrivial s :=
Expand All @@ -93,8 +93,8 @@ theorem coe_subtype : (subtype s : s → R) = ((↑) : s → R) :=
/-- A subsemiring of a `Semiring` is a `Semiring`. -/
instance (priority := 75) toSemiring {R} [Semiring R] [SetLike S R] [SubsemiringClass S R] :
Semiring s :=
Subtype.coe_injective.semiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) fun _ => rfl
Subtype.coe_injective.semiring Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl

@[simp, norm_cast]
theorem coe_pow {R} [Semiring R] [SetLike S R] [SubsemiringClass S R] (x : s) (n : ℕ) :
Expand All @@ -106,8 +106,8 @@ theorem coe_pow {R} [Semiring R] [SetLike S R] [SubsemiringClass S R] (x : s) (n
/-- A subsemiring of a `CommSemiring` is a `CommSemiring`. -/
instance toCommSemiring {R} [CommSemiring R] [SetLike S R] [SubsemiringClass S R] :
CommSemiring s :=
Subtype.coe_injective.commSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) fun _ => rfl
Subtype.coe_injective.commSemiring Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl

end SubsemiringClass

Expand Down
Loading

0 comments on commit 7aa6a93

Please sign in to comment.