From 3bc1a54d7009ff1a2c80c6be301bdafaf4e7dbd2 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Sun, 24 May 2026 17:52:06 +0200 Subject: [PATCH 01/30] test --- Mathlib/Algebra/AddConstMap/Basic.lean | 4 ++-- Mathlib/Algebra/Algebra/RestrictScalars.lean | 2 +- Mathlib/Algebra/DirectSum/Ring.lean | 14 +++++++------- Mathlib/Algebra/GradedMonoid.lean | 6 +++--- Mathlib/Algebra/Group/ULift.lean | 17 +++++++++-------- Mathlib/Algebra/GroupWithZero/ULift.lean | 11 ++++++----- Mathlib/Algebra/Homology/Additive.lean | 2 +- Mathlib/Algebra/Homology/Monoidal.lean | 2 +- Mathlib/Algebra/Lie/Basic.lean | 2 +- Mathlib/Algebra/Lie/Free.lean | 6 +++--- Mathlib/Algebra/Module/Injective.lean | 2 +- Mathlib/Algebra/Module/Submodule/Basic.lean | 2 +- Mathlib/Algebra/Module/Submodule/Order.lean | 4 ++-- Mathlib/Algebra/Module/Torsion/Basic.lean | 2 +- Mathlib/Algebra/Order/UpperLower.lean | 4 ++-- Mathlib/Algebra/Polynomial/Laurent.lean | 2 +- Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean | 4 ++-- Mathlib/Algebra/Star/NonUnitalSubalgebra.lean | 2 +- Mathlib/Algebra/Star/SelfAdjoint.lean | 14 +++++++------- Mathlib/Algebra/Star/Unitary.lean | 2 +- Mathlib/Algebra/Symmetrized.lean | 2 +- Mathlib/Analysis/Seminorm.lean | 8 ++++---- Mathlib/CategoryTheory/ConnectedComponents.lean | 2 +- Mathlib/Control/ULiftable.lean | 17 +++++++++-------- Mathlib/Data/FinEnum.lean | 4 ++-- Mathlib/Data/PFun.lean | 2 +- Mathlib/Data/UInt.lean | 4 ++-- Mathlib/Data/ULift.lean | 5 +++-- Mathlib/FieldTheory/Fixed.lean | 2 +- Mathlib/FieldTheory/PerfectClosure.lean | 8 ++++---- Mathlib/FieldTheory/PolynomialGaloisGroup.lean | 2 +- .../GroupTheory/FiniteIndexNormalSubgroup.lean | 2 +- Mathlib/GroupTheory/HNNExtension.lean | 2 +- Mathlib/GroupTheory/PushoutI.lean | 2 +- Mathlib/GroupTheory/Torsion.lean | 2 +- Mathlib/LinearAlgebra/SpecialLinearGroup.lean | 2 +- Mathlib/Logic/Denumerable.lean | 6 +++--- Mathlib/ModelTheory/Definability.lean | 2 +- Mathlib/ModelTheory/PartialEquiv.lean | 4 ++-- Mathlib/Order/Basic.lean | 7 ++++--- Mathlib/Order/BooleanSubalgebra.lean | 2 +- Mathlib/Order/CompleteSublattice.lean | 2 +- Mathlib/Order/Disjoint.lean | 3 ++- Mathlib/Order/NonemptyFiniteChains.lean | 2 +- Mathlib/Order/Nucleus.lean | 2 +- Mathlib/Order/OmegaCompletePartialOrder.lean | 6 +++--- Mathlib/Order/Shrink.lean | 2 +- Mathlib/Order/Sublattice.lean | 4 ++-- Mathlib/Order/ULift.lean | 5 +++-- Mathlib/RepresentationTheory/Basic.lean | 2 +- Mathlib/RepresentationTheory/Intertwining.lean | 4 ++-- Mathlib/RingTheory/Filtration.lean | 4 ++-- Mathlib/SetTheory/Lists.lean | 3 ++- Mathlib/Topology/Constructions.lean | 2 +- Mathlib/Topology/DiscreteQuotient.lean | 2 +- Mathlib/Topology/Path.lean | 2 +- 56 files changed, 122 insertions(+), 114 deletions(-) diff --git a/Mathlib/Algebra/AddConstMap/Basic.lean b/Mathlib/Algebra/AddConstMap/Basic.lean index 38b75c7150342a..1b2eadf3abbe2a 100644 --- a/Mathlib/Algebra/AddConstMap/Basic.lean +++ b/Mathlib/Algebra/AddConstMap/Basic.lean @@ -378,7 +378,7 @@ theorem coe_vadd {K : Type*} [VAdd K H] [VAddAssocClass K H H] (c : K) (f : G instance {K : Type*} [AddMonoid K] [AddAction K H] [VAddAssocClass K H H] : AddAction K (G →+c[a, b] H) := - DFunLike.coe_injective.addAction _ coe_vadd + fast_instance% DFunLike.coe_injective.addAction _ coe_vadd /-! ### Monoid structure on endomorphisms `G →+c[a, a] G` @@ -391,7 +391,7 @@ instance : Pow (G →+c[a, a] G) ℕ where pow f n := ⟨f^[n], Commute.iterate_left (AddConstMapClass.semiconj f) _⟩ instance : Monoid (G →+c[a, a] G) := - DFunLike.coe_injective.monoid (M₂ := Function.End G) _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.monoid (M₂ := Function.End G) _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl theorem mul_def (f g : G →+c[a, a] G) : f * g = f.comp g := rfl @[simp, push_cast] theorem coe_mul (f g : G →+c[a, a] G) : ⇑(f * g) = f ∘ g := rfl diff --git a/Mathlib/Algebra/Algebra/RestrictScalars.lean b/Mathlib/Algebra/Algebra/RestrictScalars.lean index 3e2a3022589112..3d2a09f0622b4e 100644 --- a/Mathlib/Algebra/Algebra/RestrictScalars.lean +++ b/Mathlib/Algebra/Algebra/RestrictScalars.lean @@ -138,7 +138,7 @@ The preferred way of setting this up is `[Module Rᵐᵒᵖ M] [Module Sᵐᵒᵖ M] [IsScalarTower Rᵐᵒᵖ Sᵐᵒᵖ M]`. -/ instance RestrictScalars.opModule [Module Sᵐᵒᵖ M] : Module Rᵐᵒᵖ (RestrictScalars R S M) := - letI : Module Sᵐᵒᵖ (RestrictScalars R S M) := ‹Module Sᵐᵒᵖ M› + fast_instance% letI : Module Sᵐᵒᵖ (RestrictScalars R S M) := ‹Module Sᵐᵒᵖ M› Module.compHom M (RingHom.op <| algebraMap R S) instance RestrictScalars.isCentralScalar [Module S M] [Module Sᵐᵒᵖ M] [IsCentralScalar S M] : diff --git a/Mathlib/Algebra/DirectSum/Ring.lean b/Mathlib/Algebra/DirectSum/Ring.lean index f07485c15099dd..3d440d3dec426e 100644 --- a/Mathlib/Algebra/DirectSum/Ring.lean +++ b/Mathlib/Algebra/DirectSum/Ring.lean @@ -383,7 +383,7 @@ theorem of_zero_mul (a b : A 0) : of _ 0 (a * b) = of _ 0 a * of _ 0 b := of_zero_smul A a b instance (priority := 900) GradeZero.nonUnitalNonAssocSemiring : NonUnitalNonAssocSemiring (A 0) := - Function.Injective.nonUnitalNonAssocSemiring (of A 0) DFinsupp.single_injective (of A 0).map_zero + fast_instance% Function.Injective.nonUnitalNonAssocSemiring (of A 0) DFinsupp.single_injective (of A 0).map_zero (of A 0).map_add (of_zero_mul A) (map_nsmul _) instance GradeZero.smulWithZero (i : ι) : SMulWithZero (A 0) (A i) := by @@ -419,7 +419,7 @@ theorem of_zero_ofNat (n : ℕ) [n.AtLeastTwo] : of A 0 ofNat(n) = ofNat(n) := /-- The `Semiring` structure derived from `GSemiring A`. -/ instance (priority := 900) GradeZero.semiring : Semiring (A 0) := - Function.Injective.semiring (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A) + fast_instance% Function.Injective.semiring (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A) (of A 0).map_add (of_zero_mul A) (fun _ _ ↦ (of A 0).map_nsmul _ _) (fun _ _ => of_zero_pow _ _ _) (of_natCast A) @@ -433,7 +433,7 @@ def ofZeroRingHom : A 0 →+* ⨁ i, A i := in an overall `Module (A 0) (⨁ i, A i)` structure via `DirectSum.module`. -/ instance GradeZero.module {i} : Module (A 0) (A i) := - letI := Module.compHom (⨁ i, A i) (ofZeroRingHom A) + fast_instance% letI := Module.compHom (⨁ i, A i) (ofZeroRingHom A) DFinsupp.single_injective.module (A 0) (of A i) fun a => of_zero_smul A a end Semiring @@ -444,7 +444,7 @@ variable [∀ i, AddCommMonoid (A i)] [AddCommMonoid ι] [GCommSemiring A] /-- The `CommSemiring` structure derived from `GCommSemiring A`. -/ instance (priority := 900) GradeZero.commSemiring : CommSemiring (A 0) := - Function.Injective.commSemiring (of A 0) DFinsupp.single_injective (of A 0).map_zero + fast_instance% Function.Injective.commSemiring (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A) (of A 0).map_add (of_zero_mul A) (fun _ _ ↦ map_nsmul _ _ _) (fun _ _ => of_zero_pow _ _ _) (of_natCast A) @@ -456,7 +456,7 @@ variable [∀ i, AddCommGroup (A i)] [AddZeroClass ι] [GNonUnitalNonAssocSemiri /-- The `NonUnitalNonAssocRing` derived from `GNonUnitalNonAssocSemiring A`. -/ instance (priority := 900) GradeZero.nonUnitalNonAssocRing : NonUnitalNonAssocRing (A 0) := - Function.Injective.nonUnitalNonAssocRing (of A 0) DFinsupp.single_injective (of A 0).map_zero + fast_instance% Function.Injective.nonUnitalNonAssocRing (of A 0) DFinsupp.single_injective (of A 0).map_zero (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_nsmul _ _ _) (fun _ _ ↦ map_zsmul _ _ _) @@ -475,7 +475,7 @@ theorem of_intCast (n : ℤ) : of A 0 n = n := by /-- The `Ring` derived from `GSemiring A`. -/ instance (priority := 900) GradeZero.ring : Ring (A 0) := - Function.Injective.ring (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A) + fast_instance% Function.Injective.ring (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A) (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_nsmul _ _ _) (fun _ _ ↦ map_zsmul _ _ _) (fun _ _ => of_zero_pow _ _ _) (of_natCast A) (of_intCast A) @@ -487,7 +487,7 @@ variable [∀ i, AddCommGroup (A i)] [AddCommMonoid ι] [GCommRing A] /-- The `CommRing` derived from `GCommSemiring A`. -/ instance (priority := 900) GradeZero.commRing : CommRing (A 0) := - Function.Injective.commRing (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A) + fast_instance% Function.Injective.commRing (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A) (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_nsmul _ _ _) (fun _ _ ↦ map_zsmul _ _ _) (fun _ _ => of_zero_pow _ _ _) (of_natCast A) (of_intCast A) diff --git a/Mathlib/Algebra/GradedMonoid.lean b/Mathlib/Algebra/GradedMonoid.lean index 9cd3249feff46e..dc3758ab9eb627 100644 --- a/Mathlib/Algebra/GradedMonoid.lean +++ b/Mathlib/Algebra/GradedMonoid.lean @@ -327,7 +327,7 @@ theorem mk_zero_pow (a : A 0) (n : ℕ) : mk _ (a ^ n) = mk _ a ^ n := /-- The `Monoid` structure derived from `GMonoid A`. -/ instance (priority := 900) GradeZero.monoid : Monoid (A 0) := - Function.Injective.monoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow + fast_instance% Function.Injective.monoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow end Monoid @@ -337,7 +337,7 @@ variable [AddCommMonoid ι] [GCommMonoid A] /-- The `CommMonoid` structure derived from `GCommMonoid A`. -/ instance (priority := 900) GradeZero.commMonoid : CommMonoid (A 0) := - Function.Injective.commMonoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow + fast_instance% Function.Injective.commMonoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow end Monoid @@ -354,7 +354,7 @@ def mkZeroMonoidHom : A 0 →* GradedMonoid A where /-- Each grade `A i` derives an `A 0`-action structure from `GMonoid A`. -/ instance GradeZero.mulAction {i} : MulAction (A 0) (A i) := - letI := MulAction.compHom (GradedMonoid A) (mkZeroMonoidHom A) + fast_instance% letI := MulAction.compHom (GradedMonoid A) (mkZeroMonoidHom A) Function.Injective.mulAction (mk i) sigma_mk_injective mk_zero_smul end MulAction diff --git a/Mathlib/Algebra/Group/ULift.lean b/Mathlib/Algebra/Group/ULift.lean index ba97d0e915c396..26767ba2b2dc32 100644 --- a/Mathlib/Algebra/Group/ULift.lean +++ b/Mathlib/Algebra/Group/ULift.lean @@ -7,6 +7,7 @@ module public import Mathlib.Algebra.Group.Equiv.Defs public import Mathlib.Algebra.Group.InjSurj +public import Mathlib.Tactic.FastInstance /-! # `ULift` instances for groups and monoids @@ -80,38 +81,38 @@ instance semigroup [Semigroup α] : Semigroup (ULift α) := @[to_additive] instance commSemigroup [CommSemigroup α] : CommSemigroup (ULift α) := - (Equiv.ulift.injective.commSemigroup _) fun _ _ => rfl + fast_instance% (Equiv.ulift.injective.commSemigroup _) fun _ _ => rfl @[to_additive] instance mulOneClass [MulOneClass α] : MulOneClass (ULift α) := - Equiv.ulift.injective.mulOneClass _ rfl (by intros; rfl) + fast_instance% Equiv.ulift.injective.mulOneClass _ rfl (by intros; rfl) @[to_additive] instance monoid [Monoid α] : Monoid (ULift α) := - Equiv.ulift.injective.monoid _ rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.monoid _ rfl (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance commMonoid [CommMonoid α] : CommMonoid (ULift α) := - Equiv.ulift.injective.commMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.commMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance divInvMonoid [DivInvMonoid α] : DivInvMonoid (ULift α) := - Equiv.ulift.injective.divInvMonoid _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) + fast_instance% Equiv.ulift.injective.divInvMonoid _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance group [Group α] : Group (ULift α) := - Equiv.ulift.injective.group _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) + fast_instance% Equiv.ulift.injective.group _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance commGroup [CommGroup α] : CommGroup (ULift α) := - Equiv.ulift.injective.commGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) + fast_instance% Equiv.ulift.injective.commGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance leftCancelSemigroup [LeftCancelSemigroup α] : LeftCancelSemigroup (ULift α) := - Equiv.ulift.injective.leftCancelSemigroup _ fun _ _ => rfl + fast_instance% Equiv.ulift.injective.leftCancelSemigroup _ fun _ _ => rfl @[to_additive] instance rightCancelSemigroup [RightCancelSemigroup α] : RightCancelSemigroup (ULift α) := diff --git a/Mathlib/Algebra/GroupWithZero/ULift.lean b/Mathlib/Algebra/GroupWithZero/ULift.lean index 24f8764b05ce8d..92eb5353683195 100644 --- a/Mathlib/Algebra/GroupWithZero/ULift.lean +++ b/Mathlib/Algebra/GroupWithZero/ULift.lean @@ -7,6 +7,7 @@ module public import Mathlib.Algebra.Group.ULift public import Mathlib.Algebra.GroupWithZero.InjSurj +public import Mathlib.Tactic.FastInstance /-! # `ULift` instances for groups and monoids with zero @@ -27,20 +28,20 @@ variable {α : Type u} namespace ULift instance mulZeroOneClass [MulZeroOneClass α] : MulZeroOneClass (ULift α) := - Equiv.ulift.injective.mulZeroOneClass _ rfl rfl (by intros; rfl) + fast_instance% Equiv.ulift.injective.mulZeroOneClass _ rfl rfl (by intros; rfl) instance monoidWithZero [MonoidWithZero α] : MonoidWithZero (ULift α) := - Equiv.ulift.injective.monoidWithZero _ rfl rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.monoidWithZero _ rfl rfl (fun _ _ => rfl) fun _ _ => rfl instance commMonoidWithZero [CommMonoidWithZero α] : CommMonoidWithZero (ULift α) := - Equiv.ulift.injective.commMonoidWithZero _ rfl rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.commMonoidWithZero _ rfl rfl (fun _ _ => rfl) fun _ _ => rfl instance groupWithZero [GroupWithZero α] : GroupWithZero (ULift α) := - Equiv.ulift.injective.groupWithZero _ rfl rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) + fast_instance% Equiv.ulift.injective.groupWithZero _ rfl rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl instance commGroupWithZero [CommGroupWithZero α] : CommGroupWithZero (ULift α) := - Equiv.ulift.injective.commGroupWithZero _ rfl rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) + fast_instance% Equiv.ulift.injective.commGroupWithZero _ rfl rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl end ULift diff --git a/Mathlib/Algebra/Homology/Additive.lean b/Mathlib/Algebra/Homology/Additive.lean index 9abb3df6b1d805..c97e387e007038 100644 --- a/Mathlib/Algebra/Homology/Additive.lean +++ b/Mathlib/Algebra/Homology/Additive.lean @@ -80,7 +80,7 @@ theorem zsmul_f_apply (n : ℤ) (f : C ⟶ D) (i : ι) : (n • f).f i = n • f rfl instance : AddCommGroup (C ⟶ D) := - Function.Injective.addCommGroup Hom.f HomologicalComplex.hom_f_injective + fast_instance% Function.Injective.addCommGroup Hom.f HomologicalComplex.hom_f_injective (by cat_disch) (by cat_disch) (by cat_disch) (by cat_disch) (by cat_disch) (by cat_disch) instance : Preadditive (HomologicalComplex V c) where diff --git a/Mathlib/Algebra/Homology/Monoidal.lean b/Mathlib/Algebra/Homology/Monoidal.lean index c02aaa384823ee..65978a18443b0d 100644 --- a/Mathlib/Algebra/Homology/Monoidal.lean +++ b/Mathlib/Algebra/Homology/Monoidal.lean @@ -328,7 +328,7 @@ noncomputable def Monoidal.inducingFunctorData : rfl noncomputable instance monoidalCategory : MonoidalCategory (HomologicalComplex C c) := - Monoidal.induced _ (Monoidal.inducingFunctorData C c) + fast_instance% Monoidal.induced _ (Monoidal.inducingFunctorData C c) noncomputable example {D : Type*} [Category* D] [Preadditive D] [MonoidalCategory D] [HasZeroObject D] [HasFiniteCoproducts D] [((curriedTensor D).Additive)] diff --git a/Mathlib/Algebra/Lie/Basic.lean b/Mathlib/Algebra/Lie/Basic.lean index f1a9094f84b662..6c5b48bb2da225 100644 --- a/Mathlib/Algebra/Lie/Basic.lean +++ b/Mathlib/Algebra/Lie/Basic.lean @@ -854,7 +854,7 @@ theorem smul_apply (t : R) (f : M →ₗ⁅R,L⁆ N) (m : M) : (t • f) m = t rfl instance : Module R (M →ₗ⁅R,L⁆ N) := - Function.Injective.module R + fast_instance% Function.Injective.module R { toFun := fun f => f.toLinearMap.toFun, map_zero' := rfl, map_add' := coe_add } coe_injective coe_smul diff --git a/Mathlib/Algebra/Lie/Free.lean b/Mathlib/Algebra/Lie/Free.lean index a57c27ee357639..3b446611658b78 100644 --- a/Mathlib/Algebra/Lie/Free.lean +++ b/Mathlib/Algebra/Lie/Free.lean @@ -143,11 +143,11 @@ instance : Sub (FreeLieAlgebra R X) where sub := Quot.map₂ Sub.sub (fun _ _ _ => Rel.subLeft _) fun _ _ _ => Rel.subRight _ instance : AddGroup (FreeLieAlgebra R X) := - Function.Surjective.addGroup (Quot.mk _) Quot.mk_surjective rfl (fun _ _ => rfl) + fast_instance% Function.Surjective.addGroup (Quot.mk _) Quot.mk_surjective rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl instance : AddCommSemigroup (FreeLieAlgebra R X) := - Function.Surjective.addCommSemigroup (Quot.mk _) Quot.mk_surjective fun _ _ => rfl + fast_instance% Function.Surjective.addCommSemigroup (Quot.mk _) Quot.mk_surjective fun _ _ => rfl instance : AddCommGroup (FreeLieAlgebra R X) := { (inferInstance : AddGroup (FreeLieAlgebra R X)), @@ -155,7 +155,7 @@ instance : AddCommGroup (FreeLieAlgebra R X) := instance {S : Type*} [Semiring S] [Module S R] [IsScalarTower S R R] : Module S (FreeLieAlgebra R X) := - Function.Surjective.module S ⟨⟨Quot.mk (Rel R X), rfl⟩, fun _ _ => rfl⟩ + fast_instance% Function.Surjective.module S ⟨⟨Quot.mk (Rel R X), rfl⟩, fun _ _ => rfl⟩ Quot.mk_surjective (fun _ _ => rfl) /-- Note that here we turn the `Mul` coming from the `NonUnitalNonAssocSemiring` structure diff --git a/Mathlib/Algebra/Module/Injective.lean b/Mathlib/Algebra/Module/Injective.lean index 68b5c4debd2949..64aad53b6ecc2b 100644 --- a/Mathlib/Algebra/Module/Injective.lean +++ b/Mathlib/Algebra/Module/Injective.lean @@ -142,7 +142,7 @@ instance : Min (ExtensionOf i f) where is_extension := fun _ => X1.is_extension _ } instance : PartialOrder (ExtensionOf i f) := - PartialOrder.lift _ ExtensionOf.toLinearPMap_injective + fast_instance% PartialOrder.lift _ ExtensionOf.toLinearPMap_injective instance : SemilatticeInf (ExtensionOf i f) := ExtensionOf.toLinearPMap_injective.semilatticeInf _ diff --git a/Mathlib/Algebra/Module/Submodule/Basic.lean b/Mathlib/Algebra/Module/Submodule/Basic.lean index 2c2b74ecbaee76..fa5d0882b7e5c2 100644 --- a/Mathlib/Algebra/Module/Submodule/Basic.lean +++ b/Mathlib/Algebra/Module/Submodule/Basic.lean @@ -82,7 +82,7 @@ instance isCentralScalar [SMul S R] [SMul S M] [IsScalarTower S R M] [SMul Sᵐ p.toSubMulAction.isCentralScalar instance instIsTorsionFree [Module.IsTorsionFree R M] : Module.IsTorsionFree R p := - Subtype.coe_injective.moduleIsTorsionFree _ (by simp) + fast_instance% Subtype.coe_injective.moduleIsTorsionFree _ (by simp) section AddAction diff --git a/Mathlib/Algebra/Module/Submodule/Order.lean b/Mathlib/Algebra/Module/Submodule/Order.lean index 18e0bb5ef6c105..c3da912280355d 100644 --- a/Mathlib/Algebra/Module/Submodule/Order.lean +++ b/Mathlib/Algebra/Module/Submodule/Order.lean @@ -24,14 +24,14 @@ variable [Semiring R] instance toIsOrderedAddMonoid [AddCommMonoid M] [PartialOrder M] [IsOrderedAddMonoid M] [Module R M] (S : Submodule R M) : IsOrderedAddMonoid S := - Function.Injective.isOrderedAddMonoid Subtype.val (fun _ _ => rfl) .rfl + fast_instance% Function.Injective.isOrderedAddMonoid Subtype.val (fun _ _ => rfl) .rfl /-- A submodule of an ordered cancellative additive monoid is an ordered cancellative additive monoid. -/ instance toIsOrderedCancelAddMonoid [AddCommMonoid M] [PartialOrder M] [IsOrderedCancelAddMonoid M] [Module R M] (S : Submodule R M) : IsOrderedCancelAddMonoid S := - Function.Injective.isOrderedCancelAddMonoid Subtype.val (fun _ _ => rfl) .rfl + fast_instance% Function.Injective.isOrderedCancelAddMonoid Subtype.val (fun _ _ => rfl) .rfl end OrderedMonoid diff --git a/Mathlib/Algebra/Module/Torsion/Basic.lean b/Mathlib/Algebra/Module/Torsion/Basic.lean index 31b3af552ce7d4..87f1ee40805c67 100644 --- a/Mathlib/Algebra/Module/Torsion/Basic.lean +++ b/Mathlib/Algebra/Module/Torsion/Basic.lean @@ -759,7 +759,7 @@ instance : SMul S (torsion' R M S) := rw [smul_comm, h, smul_zero]⟩⟩ instance : DistribMulAction S (torsion' R M S) := - Subtype.coe_injective.distribMulAction (torsion' R M S).subtype.toAddMonoidHom fun (_ : S) _ => + fast_instance% Subtype.coe_injective.distribMulAction (torsion' R M S).subtype.toAddMonoidHom fun (_ : S) _ => rfl instance : SMulCommClass S R (torsion' R M S) := diff --git a/Mathlib/Algebra/Order/UpperLower.lean b/Mathlib/Algebra/Order/UpperLower.lean index 73864388c338df..cfd6cb455c0cb9 100644 --- a/Mathlib/Algebra/Order/UpperLower.lean +++ b/Mathlib/Algebra/Order/UpperLower.lean @@ -132,7 +132,7 @@ theorem Ici_one : Ici (1 : α) = 1 := @[to_additive] instance : MulAction α (UpperSet α) := - SetLike.coe_injective.mulAction _ (fun _ _ => rfl) + fast_instance% SetLike.coe_injective.mulAction _ (fun _ _ => rfl) @[to_additive] instance commSemigroup : CommSemigroup (UpperSet α) := @@ -188,7 +188,7 @@ theorem Iic_one : Iic (1 : α) = 1 := @[to_additive] instance : MulAction α (LowerSet α) := - SetLike.coe_injective.mulAction _ (fun _ _ => rfl) + fast_instance% SetLike.coe_injective.mulAction _ (fun _ _ => rfl) @[to_additive] instance commSemigroup : CommSemigroup (LowerSet α) := diff --git a/Mathlib/Algebra/Polynomial/Laurent.lean b/Mathlib/Algebra/Polynomial/Laurent.lean index e3b674a50ed46d..2637e64770c4af 100644 --- a/Mathlib/Algebra/Polynomial/Laurent.lean +++ b/Mathlib/Algebra/Polynomial/Laurent.lean @@ -483,7 +483,7 @@ end DegreeBounds end Degrees instance : Module R[X] R[T;T⁻¹] := - Module.compHom _ Polynomial.toLaurent + fast_instance% Module.compHom _ Polynomial.toLaurent instance (R : Type*) [Semiring R] : IsScalarTower R[X] R[X] R[T;T⁻¹] where smul_assoc x y z := by rw [smul_eq_mul, mul_smul] diff --git a/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean b/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean index ee81cf588c266b..de287faa6e15a0 100644 --- a/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean +++ b/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean @@ -138,7 +138,7 @@ instance [Nontrivial k] [Nonempty G] : Nontrivial (SkewMonoidAlgebra k G) := Function.Injective.nontrivial ofFinsupp_injective instance [Subsingleton k] : Unique (SkewMonoidAlgebra k G) := - Function.Injective.unique toFinsupp_injective + fast_instance% Function.Injective.unique toFinsupp_injective instance : AddMonoid (SkewMonoidAlgebra k G) where __ := toFinsupp_injective.addMonoid _ toFinsupp_zero toFinsupp_add @@ -352,7 +352,7 @@ instance : AddCommMonoid (SkewMonoidAlgebra k G) where section sum instance [DecidableEq G] [DecidableEq k] : DecidableEq (SkewMonoidAlgebra k G) := - Equiv.decidableEq toFinsuppAddEquiv.toEquiv + fast_instance% Equiv.decidableEq toFinsuppAddEquiv.toEquiv /-- `sum f g` is the sum of `g a (f.coeff a)` over the support of `f`. -/ def sum {N : Type*} [AddCommMonoid N] (f : SkewMonoidAlgebra k G) (g : G → k → N) : N := diff --git a/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean b/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean index 74e8b6544b458d..9811d392d794a9 100644 --- a/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean +++ b/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean @@ -300,7 +300,7 @@ instance instSMulCommClass [SMulCommClass R A A] : SMulCommClass R S S where end instance instIsTorsionFree [IsTorsionFree R A] : IsTorsionFree R S := - Subtype.coe_injective.moduleIsTorsionFree _ (by simp) + fast_instance% Subtype.coe_injective.moduleIsTorsionFree _ (by simp) protected theorem coe_add (x y : S) : (↑(x + y) : A) = ↑x + ↑y := rfl diff --git a/Mathlib/Algebra/Star/SelfAdjoint.lean b/Mathlib/Algebra/Star/SelfAdjoint.lean index a90c986a9f1528..52a02683e4c4c4 100644 --- a/Mathlib/Algebra/Star/SelfAdjoint.lean +++ b/Mathlib/Algebra/Star/SelfAdjoint.lean @@ -439,7 +439,7 @@ section CommRing variable [CommRing R] [StarRing R] instance : CommRing (selfAdjoint R) := - Function.Injective.commRing _ Subtype.coe_injective (selfAdjoint R).coe_zero val_one + fast_instance% Function.Injective.commRing _ Subtype.coe_injective (selfAdjoint R).coe_zero val_one (selfAdjoint R).coe_add val_mul (selfAdjoint R).coe_neg (selfAdjoint R).coe_sub (by intros; rfl) (by intros; rfl) val_pow (fun _ => rfl) fun _ => rfl @@ -490,7 +490,7 @@ instance instSMulRat : SMul ℚ (selfAdjoint R) where @[simp, norm_cast] lemma val_qsmul (q : ℚ) (x : selfAdjoint R) : ↑(q • x) = q • (x : R) := rfl instance instField : Field (selfAdjoint R) := - Subtype.coe_injective.field _ (selfAdjoint R).coe_zero val_one + fast_instance% Subtype.coe_injective.field _ (selfAdjoint R).coe_zero val_one (selfAdjoint R).coe_add val_mul (selfAdjoint R).coe_neg (selfAdjoint R).coe_sub val_inv val_div (swap (selfAdjoint R).coe_nsmul) (by intros; rfl) val_nnqsmul val_qsmul val_pow val_zpow (fun _ => rfl) (fun _ => rfl) val_nnratCast val_ratCast @@ -509,10 +509,10 @@ theorem val_smul [SMul R A] [StarModule R A] (r : R) (x : selfAdjoint A) : ↑(r rfl instance [Monoid R] [MulAction R A] [StarModule R A] : MulAction R (selfAdjoint A) := - Function.Injective.mulAction Subtype.val Subtype.coe_injective val_smul + fast_instance% Function.Injective.mulAction Subtype.val Subtype.coe_injective val_smul instance [Monoid R] [DistribMulAction R A] [StarModule R A] : DistribMulAction R (selfAdjoint A) := - Function.Injective.distribMulAction (selfAdjoint A).subtype Subtype.coe_injective val_smul + fast_instance% Function.Injective.distribMulAction (selfAdjoint A).subtype Subtype.coe_injective val_smul end SMul @@ -521,7 +521,7 @@ section Module variable [Star R] [TrivialStar R] [AddCommGroup A] [StarAddMonoid A] instance [Semiring R] [Module R A] [StarModule R A] : Module R (selfAdjoint A) := - Function.Injective.module R (selfAdjoint A).subtype Subtype.coe_injective val_smul + fast_instance% Function.Injective.module R (selfAdjoint A).subtype Subtype.coe_injective val_smul end Module @@ -584,10 +584,10 @@ theorem val_smul [Monoid R] [DistribMulAction R A] [StarModule R A] (r : R) (x : rfl instance [Monoid R] [DistribMulAction R A] [StarModule R A] : DistribMulAction R (skewAdjoint A) := - Function.Injective.distribMulAction (skewAdjoint A).subtype Subtype.coe_injective val_smul + fast_instance% Function.Injective.distribMulAction (skewAdjoint A).subtype Subtype.coe_injective val_smul instance [Semiring R] [Module R A] [StarModule R A] : Module R (skewAdjoint A) := - Function.Injective.module R (skewAdjoint A).subtype Subtype.coe_injective val_smul + fast_instance% Function.Injective.module R (skewAdjoint A).subtype Subtype.coe_injective val_smul end SMul diff --git a/Mathlib/Algebra/Star/Unitary.lean b/Mathlib/Algebra/Star/Unitary.lean index 9b0427dcbda9e9..18088040158bc9 100644 --- a/Mathlib/Algebra/Star/Unitary.lean +++ b/Mathlib/Algebra/Star/Unitary.lean @@ -400,7 +400,7 @@ theorem coe_neg (U : unitary R) : ↑(-U) = (-U : R) := rfl instance : HasDistribNeg (unitary R) := - Subtype.coe_injective.hasDistribNeg _ coe_neg (unitary R).coe_mul + fast_instance% Subtype.coe_injective.hasDistribNeg _ coe_neg (unitary R).coe_mul end Ring diff --git a/Mathlib/Algebra/Symmetrized.lean b/Mathlib/Algebra/Symmetrized.lean index 87503423a78036..df8dc05be008b8 100644 --- a/Mathlib/Algebra/Symmetrized.lean +++ b/Mathlib/Algebra/Symmetrized.lean @@ -234,7 +234,7 @@ instance addCommGroup [AddCommGroup α] : AddCommGroup αˢʸᵐ := { SymAlg.addCommMonoid, SymAlg.addGroup with } instance {R : Type*} [Semiring R] [AddCommMonoid α] [Module R α] : Module R αˢʸᵐ := - Function.Injective.module R ⟨⟨unsym, unsym_zero⟩, unsym_add⟩ unsym_injective unsym_smul + fast_instance% Function.Injective.module R ⟨⟨unsym, unsym_zero⟩, unsym_add⟩ unsym_injective unsym_smul instance [Mul α] [AddMonoidWithOne α] [Invertible (2 : α)] (a : α) [Invertible a] : Invertible (sym a) where diff --git a/Mathlib/Analysis/Seminorm.lean b/Mathlib/Analysis/Seminorm.lean index 5b85fdc6f4f9dd..16a3d4c02dde48 100644 --- a/Mathlib/Analysis/Seminorm.lean +++ b/Mathlib/Analysis/Seminorm.lean @@ -183,20 +183,20 @@ theorem add_apply (p q : Seminorm 𝕜 E) (x : E) : (p + q) x = p x + q x := rfl instance instAddMonoid : AddMonoid (Seminorm 𝕜 E) := - DFunLike.coe_injective.addMonoid _ rfl coe_add fun _ _ => by rfl + fast_instance% DFunLike.coe_injective.addMonoid _ rfl coe_add fun _ _ => by rfl instance instAddCommMonoid : AddCommMonoid (Seminorm 𝕜 E) := - DFunLike.coe_injective.addCommMonoid _ rfl coe_add fun _ _ => by rfl + fast_instance% DFunLike.coe_injective.addCommMonoid _ rfl coe_add fun _ _ => by rfl instance instPartialOrder : PartialOrder (Seminorm 𝕜 E) := - PartialOrder.lift _ DFunLike.coe_injective + fast_instance% PartialOrder.lift _ DFunLike.coe_injective instance instIsOrderedCancelAddMonoid : IsOrderedCancelAddMonoid (Seminorm 𝕜 E) := Function.Injective.isOrderedCancelAddMonoid DFunLike.coe coe_add .rfl instance instMulAction [Monoid R] [MulAction R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] : MulAction R (Seminorm 𝕜 E) := - DFunLike.coe_injective.mulAction _ (by intros; rfl) + fast_instance% DFunLike.coe_injective.mulAction _ (by intros; rfl) variable (𝕜 E) diff --git a/Mathlib/CategoryTheory/ConnectedComponents.lean b/Mathlib/CategoryTheory/ConnectedComponents.lean index 49ca504b3b586c..2529a09e0f945c 100644 --- a/Mathlib/CategoryTheory/ConnectedComponents.lean +++ b/Mathlib/CategoryTheory/ConnectedComponents.lean @@ -51,7 +51,7 @@ lemma Functor.mapConnectedComponents_mk {K : Type u₂} [Category.{v₂} K] (F : F.mapConnectedComponents (Quotient.mk _ j) = Quotient.mk _ (F.obj j) := rfl instance [Inhabited J] : Inhabited (ConnectedComponents J) := - ⟨Quotient.mk'' default⟩ + fast_instance% ⟨Quotient.mk'' default⟩ /-- Every function from connected components of a category gives a functor to discrete category -/ def ConnectedComponents.functorToDiscrete (X : Type*) diff --git a/Mathlib/Control/ULiftable.lean b/Mathlib/Control/ULiftable.lean index 95571f205712d2..3dcbd3b5ec88c2 100644 --- a/Mathlib/Control/ULiftable.lean +++ b/Mathlib/Control/ULiftable.lean @@ -11,6 +11,7 @@ public import Mathlib.Control.Monad.Writer public import Mathlib.Logic.Equiv.Basic public import Mathlib.Logic.Equiv.Functor public import Mathlib.Control.Lawful +public import Mathlib.Tactic.FastInstance /-! # Universe lifting for type families @@ -128,11 +129,11 @@ def StateT.uliftable' {m : Type u₀ → Type v₀} {m' : Type u₁ → Type v StateT.equiv <| Equiv.piCongr F fun _ => ULiftable.congr <| Equiv.prodCongr G F instance {m m'} [ULiftable m m'] : ULiftable (StateT s m) (StateT (ULift s) m') := - StateT.uliftable' Equiv.ulift.symm + fast_instance% StateT.uliftable' Equiv.ulift.symm instance StateT.instULiftableULiftULift {m m'} [ULiftable m m'] : ULiftable (StateT (ULift.{max v₀ u₀} s) m) (StateT (ULift.{max v₁ u₀} s) m') := - StateT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm + fast_instance% StateT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm /-- for specific reader monads, this function helps to create a uliftable instance -/ @[implicit_reducible] @@ -141,11 +142,11 @@ def ReaderT.uliftable' {m m'} [ULiftable m m'] (F : s ≃ s') : congr G := ReaderT.equiv <| Equiv.piCongr F fun _ => ULiftable.congr G instance {m m'} [ULiftable m m'] : ULiftable (ReaderT s m) (ReaderT (ULift s) m') := - ReaderT.uliftable' Equiv.ulift.symm + fast_instance% ReaderT.uliftable' Equiv.ulift.symm instance ReaderT.instULiftableULiftULift {m m'} [ULiftable m m'] : ULiftable (ReaderT (ULift.{max v₀ u₀} s) m) (ReaderT (ULift.{max v₁ u₀} s) m') := - ReaderT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm + fast_instance% ReaderT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm /-- for specific continuation passing monads, this function helps to create a uliftable instance -/ @[implicit_reducible] @@ -154,11 +155,11 @@ def ContT.uliftable' {m m'} [ULiftable m m'] (F : r ≃ r') : congr := ContT.equiv (ULiftable.congr F) instance {s m m'} [ULiftable m m'] : ULiftable (ContT s m) (ContT (ULift s) m') := - ContT.uliftable' Equiv.ulift.symm + fast_instance% ContT.uliftable' Equiv.ulift.symm instance ContT.instULiftableULiftULift {m m'} [ULiftable m m'] : ULiftable (ContT (ULift.{max v₀ u₀} s) m) (ContT (ULift.{max v₁ u₀} s) m') := - ContT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm + fast_instance% ContT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm /-- for specific writer monads, this function helps to create a uliftable instance -/ @[implicit_reducible] @@ -167,11 +168,11 @@ def WriterT.uliftable' {m m'} [ULiftable m m'] (F : w ≃ w') : congr G := WriterT.equiv <| ULiftable.congr <| Equiv.prodCongr G F instance {m m'} [ULiftable m m'] : ULiftable (WriterT s m) (WriterT (ULift s) m') := - WriterT.uliftable' Equiv.ulift.symm + fast_instance% WriterT.uliftable' Equiv.ulift.symm instance WriterT.instULiftableULiftULift {m m'} [ULiftable m m'] : ULiftable (WriterT (ULift.{max v₀ u₀} s) m) (WriterT (ULift.{max v₁ u₀} s) m') := - WriterT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm + fast_instance% WriterT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm instance Except.instULiftable {ε : Type u₀} : ULiftable (Except.{u₀, v₁} ε) (Except.{u₀, v₂} ε) where diff --git a/Mathlib/Data/FinEnum.lean b/Mathlib/Data/FinEnum.lean index 09265e1c0735ac..94d27bc773b511 100644 --- a/Mathlib/Data/FinEnum.lean +++ b/Mathlib/Data/FinEnum.lean @@ -94,7 +94,7 @@ noncomputable def ofInjective {α β} (f : α → β) [DecidableEq α] [FinEnum simp only [h, Function.partialInv_left]) instance _root_.ULift.instFinEnum [FinEnum α] : FinEnum (ULift α) := - ⟨card α, Equiv.ulift.trans equiv⟩ + fast_instance% ⟨card α, Equiv.ulift.trans equiv⟩ @[simp] theorem card_ulift [FinEnum (ULift α)] [FinEnum α] : card (ULift α) = card α := @@ -139,7 +139,7 @@ theorem card_fin {n} [FinEnum (Fin n)] : card (Fin n) = n := Fin.equiv_iff_eq.mp instance Quotient.enum [FinEnum α] (s : Setoid α) [DecidableRel ((· ≈ ·) : α → α → Prop)] : FinEnum (Quotient s) := - FinEnum.ofSurjective Quotient.mk'' fun x => Quotient.inductionOn x fun x => ⟨x, rfl⟩ + fast_instance% FinEnum.ofSurjective Quotient.mk'' fun x => Quotient.inductionOn x fun x => ⟨x, rfl⟩ /-- enumerate all finite sets of a given type -/ def Finset.enum [DecidableEq α] : List α → List (Finset α) diff --git a/Mathlib/Data/PFun.lean b/Mathlib/Data/PFun.lean index ac172bc651d0b5..44aa10af6a7e37 100644 --- a/Mathlib/Data/PFun.lean +++ b/Mathlib/Data/PFun.lean @@ -125,7 +125,7 @@ theorem asSubtype_eq_of_mem {f : α →. β} {x : α} {y : β} (fxy : y ∈ f x) protected def lift (f : α → β) : α →. β := fun a => Part.some (f a) instance coe : Coe (α → β) (α →. β) := - ⟨PFun.lift⟩ + fast_instance% ⟨PFun.lift⟩ @[simp] theorem coe_val (f : α → β) (a : α) : (f : α →. β) a = Part.some (f a) := diff --git a/Mathlib/Data/UInt.lean b/Mathlib/Data/UInt.lean index 14225b9611b9a5..631d6e8838681f 100644 --- a/Mathlib/Data/UInt.lean +++ b/Mathlib/Data/UInt.lean @@ -90,14 +90,14 @@ run_cmd open $typeName (toBitVec_one toBitVec_mul toBitVec_pow) in instance instCommMonoid : CommMonoid $typeName := - Function.Injective.commMonoid toBitVec toBitVec_injective + fast_instance% Function.Injective.commMonoid toBitVec toBitVec_injective toBitVec_one (fun _ _ => toBitVec_mul) (fun _ _ => toBitVec_pow _ _) open $typeName ( toBitVec_zero toBitVec_add toBitVec_mul toBitVec_neg toBitVec_sub toBitVec_nsmul toBitVec_zsmul) in instance instNonUnitalCommRing : NonUnitalCommRing $typeName := - Function.Injective.nonUnitalCommRing toBitVec toBitVec_injective + fast_instance% Function.Injective.nonUnitalCommRing toBitVec toBitVec_injective toBitVec_zero (fun _ _ => toBitVec_add) (fun _ _ => toBitVec_mul) (fun _ => toBitVec_neg) (fun _ _ => toBitVec_sub) (fun _ _ => toBitVec_nsmul _ _) (fun _ _ => toBitVec_zsmul _ _) diff --git a/Mathlib/Data/ULift.lean b/Mathlib/Data/ULift.lean index 23e06effdc20b5..66108f67a5b1c7 100644 --- a/Mathlib/Data/ULift.lean +++ b/Mathlib/Data/ULift.lean @@ -7,6 +7,7 @@ module public import Mathlib.Control.ULift public import Mathlib.Logic.Equiv.Basic +public import Mathlib.Tactic.FastInstance /-! # Extra lemmas about `ULift` and `PLift` @@ -30,7 +31,7 @@ instance [Nonempty α] : Nonempty (PLift α) := Equiv.plift.nonempty instance [Unique α] : Unique (PLift α) := - Equiv.plift.unique + fast_instance% Equiv.plift.unique instance [DecidableEq α] : DecidableEq (PLift α) := Equiv.plift.decidableEq @@ -82,7 +83,7 @@ instance [Nonempty α] : Nonempty (ULift α) := Equiv.ulift.nonempty instance [Unique α] : Unique (ULift α) := - Equiv.ulift.unique + fast_instance% Equiv.ulift.unique instance [DecidableEq α] : DecidableEq (ULift α) := Equiv.ulift.decidableEq diff --git a/Mathlib/FieldTheory/Fixed.lean b/Mathlib/FieldTheory/Fixed.lean index 97a75276b87776..6e16301fab2a3f 100644 --- a/Mathlib/FieldTheory/Fixed.lean +++ b/Mathlib/FieldTheory/Fixed.lean @@ -317,7 +317,7 @@ theorem cardinalMk_algHom (K : Type u) (V : Type v) (W : Type w) [Field K] [Ring noncomputable instance AlgEquiv.fintype (K : Type u) (V : Type v) [Field K] [Field V] [Algebra K V] [FiniteDimensional K V] : Fintype (V ≃ₐ[K] V) := - Fintype.ofEquiv (V →ₐ[K] V) (algEquivEquivAlgHom K V).symm + fast_instance% Fintype.ofEquiv (V →ₐ[K] V) (algEquivEquivAlgHom K V).symm theorem finrank_algHom (K : Type u) (V : Type v) [Field K] [Field V] [Algebra K V] [FiniteDimensional K V] : Fintype.card (V →ₐ[K] V) ≤ finrank V (V →ₗ[K] V) := diff --git a/Mathlib/FieldTheory/PerfectClosure.lean b/Mathlib/FieldTheory/PerfectClosure.lean index 4696a251b56c0f..dc5d042d3ce037 100644 --- a/Mathlib/FieldTheory/PerfectClosure.lean +++ b/Mathlib/FieldTheory/PerfectClosure.lean @@ -137,7 +137,7 @@ private theorem mul_aux_right (x y1 y2 : ℕ × K) (H : R K p y1 y2) : set_option backward.privateInPublic true in set_option backward.privateInPublic.warn false in instance instMul : Mul (PerfectClosure K p) := - ⟨Quot.lift + fast_instance% ⟨Quot.lift (fun x : ℕ × K => Quot.lift (fun y : ℕ × K => @@ -205,7 +205,7 @@ private theorem add_aux_right (x y1 y2 : ℕ × K) (H : R K p y1 y2) : set_option backward.privateInPublic true in set_option backward.privateInPublic.warn false in instance instAdd : Add (PerfectClosure K p) := - ⟨Quot.lift + fast_instance% ⟨Quot.lift (fun x : ℕ × K => Quot.lift (fun y : ℕ × K => @@ -221,7 +221,7 @@ theorem mk_add_mk (x y : ℕ × K) : rfl instance instNeg : Neg (PerfectClosure K p) := - ⟨Quot.lift (fun x : ℕ × K => mk K p (x.1, -x.2)) fun x y (H : R K p x y) => + fast_instance% ⟨Quot.lift (fun x : ℕ × K => mk K p (x.1, -x.2)) fun x y (H : R K p x y) => match x, y, H with | _, _, R.intro n x => Quot.sound <| by rw [← map_neg]; apply R.intro⟩ @@ -471,7 +471,7 @@ section Field variable [Field K] (p : ℕ) [Fact p.Prime] [CharP K p] instance instInv : Inv (PerfectClosure K p) := - ⟨Quot.lift (fun x : ℕ × K => Quot.mk (R K p) (x.1, x.2⁻¹)) fun x y (H : R K p x y) => + fast_instance% ⟨Quot.lift (fun x : ℕ × K => Quot.mk (R K p) (x.1, x.2⁻¹)) fun x y (H : R K p x y) => match x, y, H with | _, _, R.intro n x => Quot.sound <| by diff --git a/Mathlib/FieldTheory/PolynomialGaloisGroup.lean b/Mathlib/FieldTheory/PolynomialGaloisGroup.lean index 32b2c0f6c70948..539b4b214b0d11 100644 --- a/Mathlib/FieldTheory/PolynomialGaloisGroup.lean +++ b/Mathlib/FieldTheory/PolynomialGaloisGroup.lean @@ -99,7 +99,7 @@ instance uniqueGalXPow (n : ℕ) : Unique (X ^ n : F[X]).Gal := uniqueGalOfSplits _ (Splits.X_pow _) instance [h : Fact ((p.map (algebraMap F E)).Splits)] : Algebra p.SplittingField E := - (IsSplittingField.lift p.SplittingField p h.1).toRingHom.toAlgebra + fast_instance% (IsSplittingField.lift p.SplittingField p h.1).toRingHom.toAlgebra instance [h : Fact ((p.map (algebraMap F E)).Splits)] : IsScalarTower F p.SplittingField E := IsScalarTower.of_algebraMap_eq fun x => diff --git a/Mathlib/GroupTheory/FiniteIndexNormalSubgroup.lean b/Mathlib/GroupTheory/FiniteIndexNormalSubgroup.lean index 05ffbe4a7f697a..f190d852d02fdb 100644 --- a/Mathlib/GroupTheory/FiniteIndexNormalSubgroup.lean +++ b/Mathlib/GroupTheory/FiniteIndexNormalSubgroup.lean @@ -84,7 +84,7 @@ instance instInfFiniteIndexNormalSubgroup : Min (FiniteIndexNormalSubgroup G) := @[to_additive] instance instSemilatticeInfFiniteIndexNormalSubgroup : SemilatticeInf (FiniteIndexNormalSubgroup G) := - SetLike.coe_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl + fast_instance% SetLike.coe_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl @[to_additive] instance : Max (FiniteIndexNormalSubgroup G) := diff --git a/Mathlib/GroupTheory/HNNExtension.lean b/Mathlib/GroupTheory/HNNExtension.lean index c9d218788c3fa2..0d5ef0bd2b0c37 100644 --- a/Mathlib/GroupTheory/HNNExtension.lean +++ b/Mathlib/GroupTheory/HNNExtension.lean @@ -480,7 +480,7 @@ theorem unitsSMul_one_group_smul (g : A) (w : NormalWord d) : rfl noncomputable instance : MulAction (HNNExtension G A B φ) (NormalWord d) := - MulAction.ofEndHom <| (MulAction.toEndHom (M := Equiv.Perm (NormalWord d))).comp + fast_instance% MulAction.ofEndHom <| (MulAction.toEndHom (M := Equiv.Perm (NormalWord d))).comp (HNNExtension.lift (MulAction.toPermHom _ _) (unitsSMulEquiv φ) <| by intro a ext : 1 diff --git a/Mathlib/GroupTheory/PushoutI.lean b/Mathlib/GroupTheory/PushoutI.lean index 31d04e07702548..a955dfd7bbf5f8 100644 --- a/Mathlib/GroupTheory/PushoutI.lean +++ b/Mathlib/GroupTheory/PushoutI.lean @@ -454,7 +454,7 @@ theorem summand_smul_def' {i : ι} (g : G i) (w : NormalWord d) : head := g * (equivPair i w).head } := rfl noncomputable instance mulAction : MulAction (PushoutI φ) (NormalWord d) := - MulAction.ofEndHom <| + fast_instance% MulAction.ofEndHom <| lift (fun _ => MulAction.toEndHom) MulAction.toEndHom <| by diff --git a/Mathlib/GroupTheory/Torsion.lean b/Mathlib/GroupTheory/Torsion.lean index 0bea82ba6422c2..7f17899b96c557 100644 --- a/Mathlib/GroupTheory/Torsion.lean +++ b/Mathlib/GroupTheory/Torsion.lean @@ -390,7 +390,7 @@ section AddCommGroup instance {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] : Module R (M ⧸ AddCommGroup.torsion M) := - -- Upgrade the torsion subgroup to a submodule. + fast_instance% -- Upgrade the torsion subgroup to a submodule. letI S : Submodule R M := { AddCommGroup.torsion M with smul_mem' := fun r m ⟨n, hn, hn'⟩ ↦ ⟨n, hn, by { simp only [Function.IsPeriodicPt, Function.IsFixedPt, add_left_iterate, add_zero, smul_comm n] at hn' ⊢; simp only [hn', smul_zero] }⟩ } diff --git a/Mathlib/LinearAlgebra/SpecialLinearGroup.lean b/Mathlib/LinearAlgebra/SpecialLinearGroup.lean index 5c8c3afb9c550b..6264ca0869c4e9 100644 --- a/Mathlib/LinearAlgebra/SpecialLinearGroup.lean +++ b/Mathlib/LinearAlgebra/SpecialLinearGroup.lean @@ -229,7 +229,7 @@ lemma mem_range_toGeneralLinearGroup_iff {u : LinearMap.GeneralLinearGroup R V} /-- The natural action of `SpecialLinearGroup R V` on `V`. -/ instance : DistribMulAction (SpecialLinearGroup R V) V := - DistribMulAction.compHom _ (SpecialLinearGroup.toLinearEquiv) + fast_instance% DistribMulAction.compHom _ (SpecialLinearGroup.toLinearEquiv) theorem _root_.SpecialLinearGroup.smul_def (g : SpecialLinearGroup R V) (v : V) : g • v = g.toLinearEquiv • v := rfl diff --git a/Mathlib/Logic/Denumerable.lean b/Mathlib/Logic/Denumerable.lean index 34609f9fc2b7cb..77f4c641e6f83e 100644 --- a/Mathlib/Logic/Denumerable.lean +++ b/Mathlib/Logic/Denumerable.lean @@ -147,7 +147,7 @@ end Sigma /-- If `α` and `β` are denumerable, then so is their product. -/ instance prod : Denumerable (α × β) := - ofEquiv _ (Equiv.sigmaEquivProd α β).symm + fast_instance% ofEquiv _ (Equiv.sigmaEquivProd α β).symm theorem prod_ofNat_val (n : ℕ) : ofNat (α × β) n = (ofNat α (unpair n).1, ofNat β (unpair n).2) := by simp @@ -163,11 +163,11 @@ instance pnat : Denumerable ℕ+ := /-- The lift of a denumerable type is denumerable. -/ instance ulift : Denumerable (ULift α) := - ofEquiv _ Equiv.ulift + fast_instance% ofEquiv _ Equiv.ulift /-- The lift of a denumerable type is denumerable. -/ instance plift : Denumerable (PLift α) := - ofEquiv _ Equiv.plift + fast_instance% ofEquiv _ Equiv.plift /-- If `α` is denumerable, then `α × α` and `α` are equivalent. -/ def pair : α × α ≃ α := diff --git a/Mathlib/ModelTheory/Definability.lean b/Mathlib/ModelTheory/Definability.lean index 11999fc7916854..27c876f0831f8c 100644 --- a/Mathlib/ModelTheory/Definability.lean +++ b/Mathlib/ModelTheory/Definability.lean @@ -427,7 +427,7 @@ theorem coe_sdiff (s t : L.DefinableSet A α) : lemma coe_himp (s t : L.DefinableSet A α) : ↑(s ⇨ t) = (s ⇨ t : Set (α → M)) := rfl noncomputable instance instBooleanAlgebra : BooleanAlgebra (L.DefinableSet A α) := - Function.Injective.booleanAlgebra _ Subtype.coe_injective .rfl .rfl + fast_instance% Function.Injective.booleanAlgebra _ Subtype.coe_injective .rfl .rfl coe_sup coe_inf coe_top coe_bot coe_compl coe_sdiff coe_himp end DefinableSet diff --git a/Mathlib/ModelTheory/PartialEquiv.lean b/Mathlib/ModelTheory/PartialEquiv.lean index 972b174ab5080c..1aad8252c7a2b6 100644 --- a/Mathlib/ModelTheory/PartialEquiv.lean +++ b/Mathlib/ModelTheory/PartialEquiv.lean @@ -67,7 +67,7 @@ variable {L M N} namespace PartialEquiv noncomputable instance instInhabited_self : Inhabited (M ≃ₚ[L] M) := - ⟨⊤, ⊤, Equiv.refl L (⊤ : L.Substructure M)⟩ + fast_instance% ⟨⊤, ⊤, Equiv.refl L (⊤ : L.Substructure M)⟩ /-- Maps to the symmetric partial equivalence. -/ def symm (f : M ≃ₚ[L] N) : N ≃ₚ[L] M where @@ -397,7 +397,7 @@ theorem countable_self_fgequiv_of_countable [Countable M] : exact Function.Embedding.countable ⟨g, g_inj⟩ instance inhabited_self_FGEquiv : Inhabited (L.FGEquiv M M) := - ⟨⟨⟨⊥, ⊥, Equiv.refl L (⊥ : L.Substructure M)⟩, fg_bot⟩⟩ + fast_instance% ⟨⟨⟨⊥, ⊥, Equiv.refl L (⊥ : L.Substructure M)⟩, fg_bot⟩⟩ instance inhabited_FGEquiv_of_IsEmpty_Constants_and_Relations [IsEmpty L.Constants] [IsEmpty (L.Relations 0)] : Inhabited (L.FGEquiv M N) := diff --git a/Mathlib/Order/Basic.lean b/Mathlib/Order/Basic.lean index 10104887c9910d..171497e5c919fe 100644 --- a/Mathlib/Order/Basic.lean +++ b/Mathlib/Order/Basic.lean @@ -13,6 +13,7 @@ public import Mathlib.Tactic.Convert public import Mathlib.Tactic.Inhabit public import Mathlib.Tactic.SimpRw public import Mathlib.Tactic.GCongr.Core +public import Mathlib.Tactic.FastInstance /-! # Basic definitions about `≤` and `<` @@ -834,10 +835,10 @@ theorem coe_lt_coe [LT α] {p : α → Prop} {x y : Subtype p} : (x : α) < y Iff.rfl instance preorder [Preorder α] (p : α → Prop) : Preorder (Subtype p) := - Preorder.lift (fun (a : Subtype p) ↦ (a : α)) + fast_instance% Preorder.lift (fun (a : Subtype p) ↦ (a : α)) instance partialOrder [PartialOrder α] (p : α → Prop) : PartialOrder (Subtype p) := - PartialOrder.lift (fun (a : Subtype p) ↦ (a : α)) Subtype.coe_injective + fast_instance% PartialOrder.lift (fun (a : Subtype p) ↦ (a : α)) Subtype.coe_injective instance decidableLE [Preorder α] [h : DecidableLE α] {p : α → Prop} : DecidableLE (Subtype p) := fun a b ↦ h a b @@ -849,7 +850,7 @@ instance decidableLT [Preorder α] [h : DecidableLT α] {p : α → Prop} : equality and decidable order in order to ensure the decidability instances are all definitionally equal. -/ instance instLinearOrder [LinearOrder α] (p : α → Prop) : LinearOrder (Subtype p) := - @LinearOrder.lift (Subtype p) _ _ ⟨fun x y ↦ ⟨max x y, max_rec' _ x.2 y.2⟩⟩ + fast_instance% @LinearOrder.lift (Subtype p) _ _ ⟨fun x y ↦ ⟨max x y, max_rec' _ x.2 y.2⟩⟩ ⟨fun x y ↦ ⟨min x y, min_rec' _ x.2 y.2⟩⟩ (fun (a : Subtype p) ↦ (a : α)) Subtype.coe_injective (fun _ _ ↦ rfl) fun _ _ ↦ rfl diff --git a/Mathlib/Order/BooleanSubalgebra.lean b/Mathlib/Order/BooleanSubalgebra.lean index 4ff2728db07ba2..26116b5168b634 100644 --- a/Mathlib/Order/BooleanSubalgebra.lean +++ b/Mathlib/Order/BooleanSubalgebra.lean @@ -126,7 +126,7 @@ instance (L : BooleanSubalgebra α) : PartialOrder L := /-- A Boolean subalgebra of a lattice inherits a Boolean algebra structure. -/ instance instBooleanAlgebraCoe (L : BooleanSubalgebra α) : BooleanAlgebra L := - Subtype.coe_injective.booleanAlgebra _ .rfl .rfl val_sup val_inf val_top val_bot val_compl + fast_instance% Subtype.coe_injective.booleanAlgebra _ .rfl .rfl val_sup val_inf val_top val_bot val_compl val_sdiff val_himp /-- The natural lattice hom from a Boolean subalgebra to the original lattice. -/ diff --git a/Mathlib/Order/CompleteSublattice.lean b/Mathlib/Order/CompleteSublattice.lean index 0b36f8921495e5..c4030425a90e19 100644 --- a/Mathlib/Order/CompleteSublattice.lean +++ b/Mathlib/Order/CompleteSublattice.lean @@ -111,7 +111,7 @@ instance : Max {x // x ∈ L} := Sublattice.instSupCoe instance : Min {x // x ∈ L} := Sublattice.instInfCoe instance instCompleteLattice : CompleteLattice L := - Subtype.coe_injective.completeLattice _ .rfl .rfl + fast_instance% Subtype.coe_injective.completeLattice _ .rfl .rfl Sublattice.coe_sup Sublattice.coe_inf coe_sSup' coe_sInf' coe_top coe_bot /-- The natural complete lattice hom from a complete sublattice to the original lattice. -/ diff --git a/Mathlib/Order/Disjoint.lean b/Mathlib/Order/Disjoint.lean index 15d567ee47e342..1f4104a7c84ec4 100644 --- a/Mathlib/Order/Disjoint.lean +++ b/Mathlib/Order/Disjoint.lean @@ -6,6 +6,7 @@ Authors: Johannes Hölzl module public import Mathlib.Order.BoundedOrder.Lattice +public import Mathlib.Tactic.FastInstance /-! # Disjointness and complements @@ -606,7 +607,7 @@ theorem mk_inf_mk {a b : α} (ha : IsComplemented a) (hb : IsComplemented b) : (⟨a, ha⟩ ⊓ ⟨b, hb⟩ : Complementeds α) = ⟨a ⊓ b, ha.inf hb⟩ := rfl instance : DistribLattice (Complementeds α) := - Complementeds.coe_injective.distribLattice _ .rfl .rfl coe_sup coe_inf + fast_instance% Complementeds.coe_injective.distribLattice _ .rfl .rfl coe_sup coe_inf @[simp, norm_cast] theorem disjoint_coe : Disjoint (a : α) b ↔ Disjoint a b := by diff --git a/Mathlib/Order/NonemptyFiniteChains.lean b/Mathlib/Order/NonemptyFiniteChains.lean index 2ed532433c3c8a..a25834f0509600 100644 --- a/Mathlib/Order/NonemptyFiniteChains.lean +++ b/Mathlib/Order/NonemptyFiniteChains.lean @@ -41,7 +41,7 @@ namespace NonemptyFiniteChains attribute [simp] nonempty instance (X : Type u) [PartialOrder X] : PartialOrder (NonemptyFiniteChains X) := - PartialOrder.lift finset (fun _ _ _ ↦ by aesop) + fast_instance% PartialOrder.lift finset (fun _ _ _ ↦ by aesop) variable {X Y : Type*} [PartialOrder X] [PartialOrder Y] diff --git a/Mathlib/Order/Nucleus.lean b/Mathlib/Order/Nucleus.lean index b8886f7068fde2..7c8fbafae149a5 100644 --- a/Mathlib/Order/Nucleus.lean +++ b/Mathlib/Order/Nucleus.lean @@ -112,7 +112,7 @@ instance : Min (Nucleus X) where @[simp] lemma inf_apply (m n : Nucleus X) (x : X) : (m ⊓ n) x = m x ⊓ n x := rfl instance : SemilatticeInf (Nucleus X) := - DFunLike.coe_injective.semilatticeInf _ .rfl .rfl coe_inf + fast_instance% DFunLike.coe_injective.semilatticeInf _ .rfl .rfl coe_inf /-- The smallest nucleus is the identity. -/ instance instBot : OrderBot (Nucleus X) where diff --git a/Mathlib/Order/OmegaCompletePartialOrder.lean b/Mathlib/Order/OmegaCompletePartialOrder.lean index 6ce92605a5d426..b9a9326db0dd88 100644 --- a/Mathlib/Order/OmegaCompletePartialOrder.lean +++ b/Mathlib/Order/OmegaCompletePartialOrder.lean @@ -475,7 +475,7 @@ protected def ωSup (c : Chain (α →o β)) : α →o β where @[simps! ωSup_coe] instance omegaCompletePartialOrder : OmegaCompletePartialOrder (α →o β) := - OmegaCompletePartialOrder.lift OrderHom.coeFnHom OrderHom.ωSup (fun _ _ h => h) fun _ => rfl + fast_instance% OmegaCompletePartialOrder.lift OrderHom.coeFnHom OrderHom.ωSup (fun _ _ h => h) fun _ => rfl end OrderHom @@ -499,7 +499,7 @@ instance : OrderHomClass (α →𝒄 β) α β where map_rel f _ _ h := f.mono h instance : PartialOrder (α →𝒄 β) := - (PartialOrder.lift fun f => f.toOrderHom.toFun) <| by rintro ⟨⟨⟩⟩ ⟨⟨⟩⟩ h; congr + fast_instance% (PartialOrder.lift fun f => f.toOrderHom.toFun) <| by rintro ⟨⟨⟩⟩ ⟨⟨⟩⟩ h; congr namespace ContinuousHom @@ -669,7 +669,7 @@ protected def ωSup (c : Chain (α →𝒄 β)) : α →𝒄 β where @[simps ωSup] instance : OmegaCompletePartialOrder (α →𝒄 β) := - OmegaCompletePartialOrder.lift ContinuousHom.toMono ContinuousHom.ωSup + fast_instance% OmegaCompletePartialOrder.lift ContinuousHom.toMono ContinuousHom.ωSup (fun _ _ h => h) (fun _ => rfl) @[fun_prop] diff --git a/Mathlib/Order/Shrink.lean b/Mathlib/Order/Shrink.lean index 45f1baf0ebd943..090b6e4ee3a66b 100644 --- a/Mathlib/Order/Shrink.lean +++ b/Mathlib/Order/Shrink.lean @@ -42,7 +42,7 @@ section Preorder variable [Preorder α] noncomputable instance : Preorder (Shrink.{u} α) := - Preorder.lift (equivShrink α).symm + fast_instance% Preorder.lift (equivShrink α).symm variable (α) in /-- The order isomorphism `α ≃o Shrink.{u} α`. -/ diff --git a/Mathlib/Order/Sublattice.lean b/Mathlib/Order/Sublattice.lean index 1bd5cbc2b04b76..b42175f846a6c9 100644 --- a/Mathlib/Order/Sublattice.lean +++ b/Mathlib/Order/Sublattice.lean @@ -102,12 +102,12 @@ instance instInfCoe : Min L where /-- A sublattice of a lattice inherits a lattice structure. -/ instance instLatticeCoe (L : Sublattice α) : Lattice L := - Subtype.coe_injective.lattice _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + fast_instance% Subtype.coe_injective.lattice _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) /-- A sublattice of a distributive lattice inherits a distributive lattice structure. -/ instance instDistribLatticeCoe {α : Type*} [DistribLattice α] (L : Sublattice α) : DistribLattice L := - Subtype.coe_injective.distribLattice _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + fast_instance% Subtype.coe_injective.distribLattice _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) /-- The natural lattice hom from a sublattice to the original lattice. -/ def subtype (L : Sublattice α) : LatticeHom L α where diff --git a/Mathlib/Order/ULift.lean b/Mathlib/Order/ULift.lean index 638cb78c7bd0f8..8c3882ea0edb65 100644 --- a/Mathlib/Order/ULift.lean +++ b/Mathlib/Order/ULift.lean @@ -7,6 +7,7 @@ module public import Mathlib.Logic.Function.ULift public import Mathlib.Order.Basic +public import Mathlib.Tactic.FastInstance /-! # Ordered structures on `ULift.{v} α` @@ -85,9 +86,9 @@ instance [LE α] [LT α] [BEq α] [Ord α] [inst : Std.LawfulBOrd α] : isLE_iff_le := inst.isLE_iff_le instance [Preorder α] : Preorder (ULift.{v} α) := - Preorder.lift ULift.down + fast_instance% Preorder.lift ULift.down instance [PartialOrder α] : PartialOrder (ULift.{v} α) := - PartialOrder.lift ULift.down ULift.down_injective + fast_instance% PartialOrder.lift ULift.down ULift.down_injective end ULift diff --git a/Mathlib/RepresentationTheory/Basic.lean b/Mathlib/RepresentationTheory/Basic.lean index c872f345fd9762..f75d6045329812 100644 --- a/Mathlib/RepresentationTheory/Basic.lean +++ b/Mathlib/RepresentationTheory/Basic.lean @@ -160,7 +160,7 @@ end /-- A `k`-linear representation of `G` on `V` can be thought of as a module over `k[G]`. -/ noncomputable instance : Module k[G] ρ.asModule := - Module.compHom V (asAlgebraHom ρ).toRingHom + fast_instance% Module.compHom V (asAlgebraHom ρ).toRingHom @[simp] theorem asModuleEquiv_map_smul (r : k[G]) (x : ρ.asModule) : diff --git a/Mathlib/RepresentationTheory/Intertwining.lean b/Mathlib/RepresentationTheory/Intertwining.lean index af86d31142a946..e4a44c8d34e0ac 100644 --- a/Mathlib/RepresentationTheory/Intertwining.lean +++ b/Mathlib/RepresentationTheory/Intertwining.lean @@ -461,13 +461,13 @@ instance : One (IntertwiningMap ρ ρ) := ⟨id ρ⟩ @[simp] lemma coe_one : ((1 : IntertwiningMap ρ ρ) : V → V) = (_root_.id : V → V) := rfl instance : Semigroup (IntertwiningMap ρ ρ) := - Function.Injective.semigroup (fun f : IntertwiningMap ρ ρ => f.toLinearMap) + fast_instance% Function.Injective.semigroup (fun f : IntertwiningMap ρ ρ => f.toLinearMap) (toLinearMap_injective ρ ρ) (coe_mul ρ) instance : Pow (IntertwiningMap ρ ρ) ℕ := ⟨fun f n => npowRecAuto n f⟩ instance : Monoid (IntertwiningMap ρ ρ) := - Function.Injective.monoid (fun f : IntertwiningMap ρ ρ => f.toLinearMap) + fast_instance% Function.Injective.monoid (fun f : IntertwiningMap ρ ρ => f.toLinearMap) (toLinearMap_injective ρ ρ) rfl (fun _ _ => rfl) (fun f n => by induction n with diff --git a/Mathlib/RingTheory/Filtration.lean b/Mathlib/RingTheory/Filtration.lean index 37b4837f7daaca..022321b584c1ed 100644 --- a/Mathlib/RingTheory/Filtration.lean +++ b/Mathlib/RingTheory/Filtration.lean @@ -159,10 +159,10 @@ theorem iInf_N {ι : Sort*} (f : ι → I.Filtration M) : (iInf f).N = ⨅ i, (f congr_arg sInf (Set.range_comp _ _).symm instance : PartialOrder (I.Filtration M) := - PartialOrder.lift _ fun _ _ ↦ Ideal.Filtration.ext + fast_instance% PartialOrder.lift _ fun _ _ ↦ Ideal.Filtration.ext instance : CompleteLattice (I.Filtration M) := - Function.Injective.completeLattice Ideal.Filtration.N + fast_instance% Function.Injective.completeLattice Ideal.Filtration.N (fun _ _ ↦ Ideal.Filtration.ext) .rfl .rfl sup_N inf_N (fun _ ↦ sSup_image) (fun _ ↦ sInf_image) top_N bot_N diff --git a/Mathlib/SetTheory/Lists.lean b/Mathlib/SetTheory/Lists.lean index 7874e79a75852c..4307362296c857 100644 --- a/Mathlib/SetTheory/Lists.lean +++ b/Mathlib/SetTheory/Lists.lean @@ -10,6 +10,7 @@ public import Mathlib.Algebra.Order.Monoid.NatCast public import Mathlib.Algebra.Ring.Nat public import Mathlib.Data.Sigma.Basic public import Batteries.Tactic.Lint.TypeClass +public import Mathlib.Tactic.FastInstance /-! # A computable model of ZFA without infinity @@ -309,7 +310,7 @@ theorem Equiv.trans : ∀ {l₁ l₂ l₃ : Lists α}, l₁ ~ l₂ → l₂ ~ l simpa using ⟨IH₁, IH₂⟩ instance instSetoidLists : Setoid (Lists α) := - ⟨(· ~ ·), Equiv.refl, @Equiv.symm _, @Equiv.trans _⟩ + fast_instance% ⟨(· ~ ·), Equiv.refl, @Equiv.symm _, @Equiv.trans _⟩ section Decidable diff --git a/Mathlib/Topology/Constructions.lean b/Mathlib/Topology/Constructions.lean index 03c4a57177fd18..e3c6c3912bd712 100644 --- a/Mathlib/Topology/Constructions.lean +++ b/Mathlib/Topology/Constructions.lean @@ -57,7 +57,7 @@ instance {r : X → X → Prop} [t : TopologicalSpace X] : TopologicalSpace (Quo instance instTopologicalSpaceQuotient {s : Setoid X} [t : TopologicalSpace X] : TopologicalSpace (Quotient s) := - coinduced Quotient.mk' t + fast_instance% coinduced Quotient.mk' t instance instTopologicalSpaceSigma {ι : Type*} {X : ι → Type v} [t₂ : ∀ i, TopologicalSpace (X i)] : TopologicalSpace (Sigma X) := diff --git a/Mathlib/Topology/DiscreteQuotient.lean b/Mathlib/Topology/DiscreteQuotient.lean index a690f782ef8391..e77249c75c07d5 100644 --- a/Mathlib/Topology/DiscreteQuotient.lean +++ b/Mathlib/Topology/DiscreteQuotient.lean @@ -143,7 +143,7 @@ instance : Min (DiscreteQuotient X) := ⟨fun S₁ S₂ => ⟨S₁.1 ⊓ S₂.1, fun x => (S₁.2 x).inter (S₂.2 x)⟩⟩ instance : PartialOrder (DiscreteQuotient X) := - PartialOrder.lift _ toSetoid_injective + fast_instance% PartialOrder.lift _ toSetoid_injective instance : SemilatticeInf (DiscreteQuotient X) := toSetoid_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl diff --git a/Mathlib/Topology/Path.lean b/Mathlib/Topology/Path.lean index 13bbc3699273fe..db9426e5f22c4a 100644 --- a/Mathlib/Topology/Path.lean +++ b/Mathlib/Topology/Path.lean @@ -175,7 +175,7 @@ open ContinuousMap compact-open topology on the space `C(I,X)` of continuous maps from `I` to `X`. -/ instance instTopologicalSpace : TopologicalSpace (Path x y) := - TopologicalSpace.induced ((↑) : _ → C(I, X)) ContinuousMap.compactOpen + fast_instance% TopologicalSpace.induced ((↑) : _ → C(I, X)) ContinuousMap.compactOpen instance : ContinuousEval (Path x y) I X := .of_continuous_forget continuous_induced_dom From 43f37f0eb5cacaf5f1bfa6eb2626387463c823b2 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Sun, 24 May 2026 17:53:30 +0200 Subject: [PATCH 02/30] more files --- Mathlib/Algebra/Group/TypeTags/Finite.lean | 4 +- Mathlib/Algebra/Group/ULift.lean | 10 +- .../Homology/DerivedCategory/Ext/Linear.lean | 2 +- .../DerivedCategory/HomologySequence.lean | 2 +- .../HomotopyCategory/ShiftSequence.lean | 2 +- Mathlib/Algebra/Lie/Derivation/Basic.lean | 4 +- Mathlib/Algebra/Module/Submodule/Basic.lean | 2 +- Mathlib/Algebra/Module/Submodule/Order.lean | 4 +- Mathlib/Algebra/Order/CauSeq/Basic.lean | 2 +- Mathlib/Algebra/Order/Group/Action/Flag.lean | 2 +- Mathlib/Algebra/Order/Hom/Ring.lean | 4 +- Mathlib/Algebra/Order/Monoid/Units.lean | 5 +- Mathlib/Algebra/Order/Nonneg/Ring.lean | 2 +- Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean | 2 +- Mathlib/Analysis/Seminorm.lean | 2 +- scripts/sweep_fast_instance.py | 355 ++++++++++++++++++ 16 files changed, 380 insertions(+), 24 deletions(-) create mode 100755 scripts/sweep_fast_instance.py diff --git a/Mathlib/Algebra/Group/TypeTags/Finite.lean b/Mathlib/Algebra/Group/TypeTags/Finite.lean index e3601f1d6a38fd..a3212eda4d2789 100644 --- a/Mathlib/Algebra/Group/TypeTags/Finite.lean +++ b/Mathlib/Algebra/Group/TypeTags/Finite.lean @@ -32,10 +32,10 @@ instance [h : Infinite α] : Infinite (Additive α) := h instance [h : Infinite α] : Infinite (Multiplicative α) := h instance Additive.fintype : ∀ [Fintype α], Fintype (Additive α) := - Fintype.ofEquiv α Additive.ofMul + fast_instance% Fintype.ofEquiv α Additive.ofMul instance Multiplicative.fintype : ∀ [Fintype α], Fintype (Multiplicative α) := - Fintype.ofEquiv α Multiplicative.ofAdd + fast_instance% Fintype.ofEquiv α Multiplicative.ofAdd @[simp] lemma Fintype.card_multiplicative (α : Type*) [Fintype α] : card (Multiplicative α) = card α := Finset.card_map _ diff --git a/Mathlib/Algebra/Group/ULift.lean b/Mathlib/Algebra/Group/ULift.lean index 26767ba2b2dc32..58e68008f8812e 100644 --- a/Mathlib/Algebra/Group/ULift.lean +++ b/Mathlib/Algebra/Group/ULift.lean @@ -116,23 +116,23 @@ instance leftCancelSemigroup [LeftCancelSemigroup α] : LeftCancelSemigroup (ULi @[to_additive] instance rightCancelSemigroup [RightCancelSemigroup α] : RightCancelSemigroup (ULift α) := - Equiv.ulift.injective.rightCancelSemigroup _ fun _ _ => rfl + fast_instance% Equiv.ulift.injective.rightCancelSemigroup _ fun _ _ => rfl @[to_additive] instance leftCancelMonoid [LeftCancelMonoid α] : LeftCancelMonoid (ULift α) := - Equiv.ulift.injective.leftCancelMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.leftCancelMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance rightCancelMonoid [RightCancelMonoid α] : RightCancelMonoid (ULift α) := - Equiv.ulift.injective.rightCancelMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.rightCancelMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance cancelMonoid [CancelMonoid α] : CancelMonoid (ULift α) := - Equiv.ulift.injective.cancelMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.cancelMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance cancelCommMonoid [CancelCommMonoid α] : CancelCommMonoid (ULift α) := - Equiv.ulift.injective.cancelCommMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.cancelCommMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl instance nontrivial [Nontrivial α] : Nontrivial (ULift α) := Equiv.ulift.symm.injective.nontrivial diff --git a/Mathlib/Algebra/Homology/DerivedCategory/Ext/Linear.lean b/Mathlib/Algebra/Homology/DerivedCategory/Ext/Linear.lean index 29c7db554d593e..3e38efba43e64a 100644 --- a/Mathlib/Algebra/Homology/DerivedCategory/Ext/Linear.lean +++ b/Mathlib/Algebra/Homology/DerivedCategory/Ext/Linear.lean @@ -37,7 +37,7 @@ variable {R : Type t} [Ring R] {C : Type u} [Category.{v} C] [Abelian C] [Linear variable {X Y : C} {n : ℕ} noncomputable instance : Module R (Ext X Y n) := - letI := HasDerivedCategory.standard C + fast_instance% letI := HasDerivedCategory.standard C Equiv.module R homEquiv lemma smul_eq_comp_mk₀ (x : Ext X Y n) (r : R) : diff --git a/Mathlib/Algebra/Homology/DerivedCategory/HomologySequence.lean b/Mathlib/Algebra/Homology/DerivedCategory/HomologySequence.lean index 153b2dca2e2317..4a1cc0851c7d41 100644 --- a/Mathlib/Algebra/Homology/DerivedCategory/HomologySequence.lean +++ b/Mathlib/Algebra/Homology/DerivedCategory/HomologySequence.lean @@ -91,7 +91,7 @@ instance (n : ℤ) : (homologyFunctor C n).IsHomological := /-- The functors `homologyFunctor C n : DerivedCategory C ⥤ C` for all `n : ℤ` are part of a "shift sequence", i.e. they satisfy compatibilities with shifts. -/ noncomputable instance : (homologyFunctor C 0).ShiftSequence ℤ := - Functor.ShiftSequence.induced (homologyFunctorFactorsh C 0) ℤ + fast_instance% Functor.ShiftSequence.induced (homologyFunctorFactorsh C 0) ℤ (homologyFunctor C) (homologyFunctorFactorsh C) lemma shift_homologyFunctor (n : ℤ) : diff --git a/Mathlib/Algebra/Homology/HomotopyCategory/ShiftSequence.lean b/Mathlib/Algebra/Homology/HomotopyCategory/ShiftSequence.lean index d53625a15f7d20..bcd425ccb037be 100644 --- a/Mathlib/Algebra/Homology/HomotopyCategory/ShiftSequence.lean +++ b/Mathlib/Algebra/Homology/HomotopyCategory/ShiftSequence.lean @@ -185,7 +185,7 @@ variable [CategoryWithHomology C] noncomputable instance : (homologyFunctor C (ComplexShape.up ℤ) 0).ShiftSequence ℤ := - Functor.ShiftSequence.induced (homologyFunctorFactors C (ComplexShape.up ℤ) 0) ℤ + fast_instance% Functor.ShiftSequence.induced (homologyFunctorFactors C (ComplexShape.up ℤ) 0) ℤ (homologyFunctor C (ComplexShape.up ℤ)) (homologyFunctorFactors C (ComplexShape.up ℤ)) diff --git a/Mathlib/Algebra/Lie/Derivation/Basic.lean b/Mathlib/Algebra/Lie/Derivation/Basic.lean index c451e6297aba17..b701de8e835f82 100644 --- a/Mathlib/Algebra/Lie/Derivation/Basic.lean +++ b/Mathlib/Algebra/Lie/Derivation/Basic.lean @@ -271,7 +271,7 @@ def coeFnAddMonoidHom : LieDerivation R L M →+ L → M where lemma coeFnAddMonoidHom_apply (D : LieDerivation R L M) : coeFnAddMonoidHom D = D := rfl instance : DistribMulAction S (LieDerivation R L M) := - Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective coe_smul + fast_instance% Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective coe_smul instance [SMul S T] [IsScalarTower S T M] : IsScalarTower S T (LieDerivation R L M) := ⟨fun _ _ _ => ext fun _ => smul_assoc _ _ _⟩ @@ -283,7 +283,7 @@ end Scalar instance instModule {S : Type*} [Semiring S] [Module S M] [SMulCommClass R S M] [SMulBracketCommClass S L M] : Module S (LieDerivation R L M) := - Function.Injective.module S coeFnAddMonoidHom coe_injective coe_smul + fast_instance% Function.Injective.module S coeFnAddMonoidHom coe_injective coe_smul end diff --git a/Mathlib/Algebra/Module/Submodule/Basic.lean b/Mathlib/Algebra/Module/Submodule/Basic.lean index fa5d0882b7e5c2..2c2b74ecbaee76 100644 --- a/Mathlib/Algebra/Module/Submodule/Basic.lean +++ b/Mathlib/Algebra/Module/Submodule/Basic.lean @@ -82,7 +82,7 @@ instance isCentralScalar [SMul S R] [SMul S M] [IsScalarTower S R M] [SMul Sᵐ p.toSubMulAction.isCentralScalar instance instIsTorsionFree [Module.IsTorsionFree R M] : Module.IsTorsionFree R p := - fast_instance% Subtype.coe_injective.moduleIsTorsionFree _ (by simp) + Subtype.coe_injective.moduleIsTorsionFree _ (by simp) section AddAction diff --git a/Mathlib/Algebra/Module/Submodule/Order.lean b/Mathlib/Algebra/Module/Submodule/Order.lean index c3da912280355d..18e0bb5ef6c105 100644 --- a/Mathlib/Algebra/Module/Submodule/Order.lean +++ b/Mathlib/Algebra/Module/Submodule/Order.lean @@ -24,14 +24,14 @@ variable [Semiring R] instance toIsOrderedAddMonoid [AddCommMonoid M] [PartialOrder M] [IsOrderedAddMonoid M] [Module R M] (S : Submodule R M) : IsOrderedAddMonoid S := - fast_instance% Function.Injective.isOrderedAddMonoid Subtype.val (fun _ _ => rfl) .rfl + Function.Injective.isOrderedAddMonoid Subtype.val (fun _ _ => rfl) .rfl /-- A submodule of an ordered cancellative additive monoid is an ordered cancellative additive monoid. -/ instance toIsOrderedCancelAddMonoid [AddCommMonoid M] [PartialOrder M] [IsOrderedCancelAddMonoid M] [Module R M] (S : Submodule R M) : IsOrderedCancelAddMonoid S := - fast_instance% Function.Injective.isOrderedCancelAddMonoid Subtype.val (fun _ _ => rfl) .rfl + Function.Injective.isOrderedCancelAddMonoid Subtype.val (fun _ _ => rfl) .rfl end OrderedMonoid diff --git a/Mathlib/Algebra/Order/CauSeq/Basic.lean b/Mathlib/Algebra/Order/CauSeq/Basic.lean index 68952d25c4f114..dbdf5522c12676 100644 --- a/Mathlib/Algebra/Order/CauSeq/Basic.lean +++ b/Mathlib/Algebra/Order/CauSeq/Basic.lean @@ -324,7 +324,7 @@ instance : IsScalarTower G (CauSeq β abv) (CauSeq β abv) := end SMul instance addGroup : AddGroup (CauSeq β abv) := - Function.Injective.addGroup Subtype.val Subtype.val_injective rfl coe_add coe_neg coe_sub + fast_instance% Function.Injective.addGroup Subtype.val Subtype.val_injective rfl coe_add coe_neg coe_sub (fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _ instance instNatCast : NatCast (CauSeq β abv) := ⟨fun n => const n⟩ diff --git a/Mathlib/Algebra/Order/Group/Action/Flag.lean b/Mathlib/Algebra/Order/Group/Action/Flag.lean index ed4c56bc857063..2ad04008f6ab8c 100644 --- a/Mathlib/Algebra/Order/Group/Action/Flag.lean +++ b/Mathlib/Algebra/Order/Group/Action/Flag.lean @@ -29,6 +29,6 @@ instance : SMul (α ≃o α) (Flag α) where smul e := map e @[simp, norm_cast] lemma coe_smul (e : α ≃o α) (s : Flag α) : (↑(e • s) : Set α) = e • s := rfl -instance : MulAction (α ≃o α) (Flag α) := SetLike.coe_injective.mulAction _ coe_smul +instance : MulAction (α ≃o α) (Flag α) := fast_instance% SetLike.coe_injective.mulAction _ coe_smul end Flag diff --git a/Mathlib/Algebra/Order/Hom/Ring.lean b/Mathlib/Algebra/Order/Hom/Ring.lean index d78055b1526ca8..c6510cd6bc9a99 100644 --- a/Mathlib/Algebra/Order/Hom/Ring.lean +++ b/Mathlib/Algebra/Order/Hom/Ring.lean @@ -278,10 +278,10 @@ end Preorder variable [NonAssocSemiring β] instance [Preorder β] : Preorder (OrderRingHom α β) := - Preorder.lift ((⇑) : _ → α → β) + fast_instance% Preorder.lift ((⇑) : _ → α → β) instance [PartialOrder β] : PartialOrder (OrderRingHom α β) := - PartialOrder.lift _ DFunLike.coe_injective + fast_instance% PartialOrder.lift _ DFunLike.coe_injective end OrderRingHom diff --git a/Mathlib/Algebra/Order/Monoid/Units.lean b/Mathlib/Algebra/Order/Monoid/Units.lean index a2c4b062dccaea..e606ed10fd1d98 100644 --- a/Mathlib/Algebra/Order/Monoid/Units.lean +++ b/Mathlib/Algebra/Order/Monoid/Units.lean @@ -7,6 +7,7 @@ module public import Mathlib.Order.Hom.Basic public import Mathlib.Algebra.Group.Units.Defs +public import Mathlib.Tactic.FastInstance /-! # Units in ordered monoids @@ -20,7 +21,7 @@ variable {α : Type*} @[to_additive] instance [Monoid α] [Preorder α] : Preorder αˣ := - Preorder.lift val + fast_instance% Preorder.lift val @[to_additive (attr := simp, norm_cast)] theorem val_le_val [Monoid α] [Preorder α] {a b : αˣ} : (a : α) ≤ b ↔ a ≤ b := @@ -32,7 +33,7 @@ theorem val_lt_val [Monoid α] [Preorder α] {a b : αˣ} : (a : α) < b ↔ a < @[to_additive] instance instPartialOrderUnits [Monoid α] [PartialOrder α] : PartialOrder αˣ := - PartialOrder.lift val val_injective + fast_instance% PartialOrder.lift val val_injective @[to_additive] instance [Monoid α] [LinearOrder α] : Max αˣ where diff --git a/Mathlib/Algebra/Order/Nonneg/Ring.lean b/Mathlib/Algebra/Order/Nonneg/Ring.lean index 3a34a803638f25..ed108e156af298 100644 --- a/Mathlib/Algebra/Order/Nonneg/Ring.lean +++ b/Mathlib/Algebra/Order/Nonneg/Ring.lean @@ -50,7 +50,7 @@ instance isOrderedAddMonoid [AddCommMonoid α] [PartialOrder α] [IsOrderedAddMo instance isOrderedCancelAddMonoid [AddCommMonoid α] [PartialOrder α] [IsOrderedCancelAddMonoid α] : IsOrderedCancelAddMonoid { x : α // 0 ≤ x } := - Function.Injective.isOrderedCancelAddMonoid _ Nonneg.coe_add .rfl + fast_instance% Function.Injective.isOrderedCancelAddMonoid _ Nonneg.coe_add .rfl instance isOrderedRing [Semiring α] [PartialOrder α] [IsOrderedRing α] : IsOrderedRing { x : α // 0 ≤ x } := diff --git a/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean b/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean index de287faa6e15a0..9defef44cec6e7 100644 --- a/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean +++ b/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean @@ -352,7 +352,7 @@ instance : AddCommMonoid (SkewMonoidAlgebra k G) where section sum instance [DecidableEq G] [DecidableEq k] : DecidableEq (SkewMonoidAlgebra k G) := - fast_instance% Equiv.decidableEq toFinsuppAddEquiv.toEquiv + Equiv.decidableEq toFinsuppAddEquiv.toEquiv /-- `sum f g` is the sum of `g a (f.coeff a)` over the support of `f`. -/ def sum {N : Type*} [AddCommMonoid N] (f : SkewMonoidAlgebra k G) (g : G → k → N) : N := diff --git a/Mathlib/Analysis/Seminorm.lean b/Mathlib/Analysis/Seminorm.lean index 16a3d4c02dde48..7313ff90ec38a2 100644 --- a/Mathlib/Analysis/Seminorm.lean +++ b/Mathlib/Analysis/Seminorm.lean @@ -257,7 +257,7 @@ theorem lt_def {p q : Seminorm 𝕜 E} : p < q ↔ p ≤ q ∧ ∃ x, p x < q x @Pi.lt_def _ _ _ p q instance instSemilatticeSup : SemilatticeSup (Seminorm 𝕜 E) := - DFunLike.coe_injective.semilatticeSup _ .rfl .rfl coe_sup + fast_instance% DFunLike.coe_injective.semilatticeSup _ .rfl .rfl coe_sup end SMul diff --git a/scripts/sweep_fast_instance.py b/scripts/sweep_fast_instance.py new file mode 100755 index 00000000000000..8212e9a760680c --- /dev/null +++ b/scripts/sweep_fast_instance.py @@ -0,0 +1,355 @@ +#!/usr/bin/env python3 +"""sweep_fast_instance.py + +Wrap mathlib instance bodies whose RHS uses a known smart constructor with +`fast_instance%`. Keep the edit only if the file still builds *and* the +`linter.fast_instance_existing` warning does not fire. + +Usage: + # dry run over a subtree, just report candidates + python3 sweep_fast_instance.py --dry-run Mathlib/Algebra/Order + + # really edit and verify, single file + python3 sweep_fast_instance.py Mathlib/Algebra/Order/Monoid/Basic.lean + + # parallel sweep + python3 sweep_fast_instance.py -j8 Mathlib + +Run from the mathlib repo root. +""" + +from __future__ import annotations + +import argparse +import re +import shutil +import subprocess +import sys +from concurrent.futures import ProcessPoolExecutor, as_completed +from pathlib import Path + +# --------------------------------------------------------------------------- +# Patterns +# --------------------------------------------------------------------------- + +# Smart-constructor names observed in existing `fast_instance%` uses across +# mathlib. Misses are fine — they simply won't be auto-swept. +SMART = re.compile( + r"""\b( + Function\.Injective\.\w+ + | Function\.Surjective\.\w+ + | \w+\.coe_injective\.\w+ # DFunLike / SetLike-style + | \w+\.(induced|lift|copy|compHom) # NormedGroup.induced, PartialOrder.lift, ... + | Equiv\.\w+ + | \w+\.ofMinimalAxioms + | \w+\.ofCoreReplaceAll + | Fintype\.ofEquiv + | Quotient\.mk + | Denumerable\.mk + )\b""", + re.VERBOSE, +) + +# Anchor at the `instance` keyword at line start; everything past it is parsed +# in Python to avoid regex backtracking on multi-line declarations. +INSTANCE_HEAD = re.compile( + r"(?m)^(?P[ \t]*)(?:noncomputable[ \t]+)?instance\b" +) + +# Messages that mean: revert the edit. Each is a warning lake prints when +# `fast_instance%` is inappropriate (linter, or Prop-class case from FastInstance.lean). +BAD_MESSAGES = ( + "Please use `inferInstance` instead of `fast_instance%`", + "is a proof, which does not need normalization", +) + +UNKNOWN_FAST_INSTANCE = "Unknown identifier `fast_instance`" + +# Body prefixes for which `fast_instance%` is either redundant or unhelpful. +_BAD_BODY_PREFIXES = ( + "fast_instance%", + "inferInstanceAs%", + "inferInstanceAs", + "inferInstance", + "{", +) + +# --------------------------------------------------------------------------- +# Edit logic +# --------------------------------------------------------------------------- + +def _skip_comment(text: str, j: int) -> int | None: + """If position j starts a comment, return position right after it; else None.""" + if text.startswith("--", j): + nl = text.find("\n", j) + return len(text) if nl < 0 else nl + if text.startswith("/-", j): + end = text.find("-/", j + 2) + return len(text) if end < 0 else end + 2 + return None + + +def _find_body(text: str, after_kw: int, head_indent: int): + """Starting just past an `instance` keyword, find the body. Returns + (body_start, body_end) or None to skip (e.g. `where` block, no `:=`).""" + n = len(text) + depth = 0 + j = after_kw + while j < n: + skip = _skip_comment(text, j) + if skip is not None: + j = skip + continue + c = text[j] + if c in "([{": + depth += 1 + j += 1 + continue + if c in ")]}": + depth -= 1 + j += 1 + continue + if depth == 0: + if text.startswith(":=", j): + body_start = j + 2 + while body_start < n and text[body_start] in " \t": + body_start += 1 + if body_start < n and text[body_start] == "\n": + body_start += 1 + while body_start < n and text[body_start] in " \t": + body_start += 1 + body_end = body_start + while body_end < n: + nl = text.find("\n", body_end) + if nl < 0: + body_end = n + break + line_start = nl + 1 + col = 0 + while line_start + col < n and text[line_start + col] in " \t": + col += 1 + if line_start + col >= n or text[line_start + col] == "\n": + body_end = nl + break + if col <= head_indent: + body_end = nl + break + body_end = nl + 1 + return body_start, body_end + if (text.startswith("where", j) + and (j + 5 >= n + or not (text[j + 5].isalnum() or text[j + 5] == "_"))): + return None + if c == "\n": + line_start = j + 1 + col = 0 + while line_start + col < n and text[line_start + col] in " \t": + col += 1 + if (line_start + col < n + and text[line_start + col] != "\n" + and col <= head_indent): + return None + j += 1 + return None + + +def candidate_edits(text: str) -> list[tuple[int, int, str]]: + """Return [(start, end, replacement), ...] for instance declarations whose + body looks like a smart-constructor application.""" + out: list[tuple[int, int, str]] = [] + pos = 0 + while True: + m = INSTANCE_HEAD.search(text, pos) + if m is None: + break + head_indent = len(m.group("indent")) + found = _find_body(text, m.end(), head_indent) + if found is None: + pos = m.end() + continue + body_start, body_end = found + body = text[body_start:body_end] + body_stripped = body.lstrip() + if (body_stripped.startswith(_BAD_BODY_PREFIXES) + or body_stripped.startswith("by ") + or body_stripped.startswith("by\n") + or body_stripped.rstrip() == "by"): + pos = body_end + continue + if SMART.search(body) is None: + pos = body_end + continue + trimmed = body.rstrip() + repl = "fast_instance% " + trimmed + out.append((body_start, body_start + len(trimmed), repl)) + pos = body_end + return out + + +def apply_edits(text: str, edits: list[tuple[int, int, str]], + picked: set[int]) -> str: + """Apply the subset of edits given by `picked` (indices into `edits`).""" + out, off = text, 0 + for i, (s, e, r) in enumerate(edits): + if i not in picked: + continue + out = out[: s + off] + r + out[e + off :] + off += len(r) - (e - s) + return out + + +# --------------------------------------------------------------------------- +# Build / verify +# --------------------------------------------------------------------------- + +def build(file: Path, repo_root: Path) -> tuple[bool, str]: + """Elaborate `file` using cached deps. Returns (success, combined output).""" + r = subprocess.run( + ["lake", "env", "lean", str(file)], + capture_output=True, text=True, cwd=repo_root, + ) + return r.returncode == 0, r.stdout + r.stderr + + +def edit_ok(file: Path, text: str, repo_root: Path) -> bool: + file.write_text(text) + ok, log = build(file, repo_root) + if not ok: + return False + return all(msg not in log for msg in BAD_MESSAGES) + + +_IMPORT_RE = re.compile(r"(?m)^(?:public\s+)?import\s+\S+[ \t]*$") +_MODULE_RE = re.compile(r"(?m)^module[ \t]*$") + + +def add_fast_instance_import(text: str) -> str: + """If `Mathlib.Tactic.FastInstance` isn't imported, add it after the last + existing import. Returns original text if no `import` lines exist or the + import is already present.""" + if "Mathlib.Tactic.FastInstance" in text: + return text + last = None + for m in _IMPORT_RE.finditer(text): + last = m + if last is None: + return text + is_module = bool(_MODULE_RE.search(text[:last.end()])) + line = ("public import Mathlib.Tactic.FastInstance" + if is_module else "import Mathlib.Tactic.FastInstance") + return text[:last.end()] + "\n" + line + text[last.end():] + + +# --------------------------------------------------------------------------- +# Per-file sweep +# --------------------------------------------------------------------------- + +def sweep(file: Path, repo_root: Path, dry_run: bool) -> tuple[int, int]: + """Return (n_candidates, n_kept). On dry-run, n_kept == 0 and nothing changes.""" + orig = file.read_text() + edits = candidate_edits(orig) + if not edits: + return 0, 0 + if dry_run: + return len(edits), 0 + + # Probe: is `fast_instance%` available in this file's import closure? + file.write_text(apply_edits(orig, edits, {0})) + _, probe_log = build(file, repo_root) + if UNKNOWN_FAST_INSTANCE in probe_log: + new_orig = add_fast_instance_import(orig) + if new_orig == orig: + file.write_text(orig); build(file, repo_root) + return len(edits), 0 + base = new_orig + edits = candidate_edits(base) # re-scan: offsets shift after import line + if not edits: + file.write_text(orig); build(file, repo_root) + return 0, 0 + else: + base = orig + + pool = set(range(len(edits))) + + if edit_ok(file, apply_edits(base, edits, pool), repo_root): + return len(edits), len(pool) + + # Fallback: incrementally accumulate compatible edits. + kept: set[int] = set() + for i in range(len(edits)): + if edit_ok(file, apply_edits(base, edits, kept | {i}), repo_root): + kept.add(i) + if kept: + file.write_text(apply_edits(base, edits, kept)) + else: + file.write_text(orig) + build(file, repo_root) + return len(edits), len(kept) + + +# --------------------------------------------------------------------------- +# CLI +# --------------------------------------------------------------------------- + +def find_files(roots: list[str]) -> list[Path]: + files: list[Path] = [] + for r in roots: + p = Path(r) + if p.is_file() and p.suffix == ".lean": + files.append(p) + else: + files.extend(p.rglob("*.lean")) + # Prefilter: only files that have at least one candidate. Keeps the worker + # pool from spawning useless rebuilds. + return [f for f in files if candidate_edits(f.read_text())] + + +def _worker(args): + file, repo_root, dry_run = args + try: + return file, sweep(file, repo_root, dry_run), None + except Exception as e: + return file, (0, 0), repr(e) + + +def main(): + ap = argparse.ArgumentParser(description=__doc__) + ap.add_argument("paths", nargs="+", help="files or directories to sweep") + ap.add_argument("-j", "--jobs", type=int, default=1, + help="parallel workers (default 1)") + ap.add_argument("--dry-run", action="store_true", + help="report candidates without editing or building") + args = ap.parse_args() + + repo_root = Path.cwd() + if not (repo_root / "lakefile.lean").exists() \ + and not (repo_root / "lakefile.toml").exists(): + sys.exit("error: run from mathlib repo root (no lakefile here)") + + files = find_files(args.paths) + print(f"# scanning {len(files)} candidate file(s)") + total_cand = total_kept = 0 + + work = [(f, repo_root, args.dry_run) for f in files] + if args.jobs > 1 and not args.dry_run: + with ProcessPoolExecutor(max_workers=args.jobs) as ex: + for fut in as_completed([ex.submit(_worker, w) for w in work]): + f, (n_cand, n_kept), err = fut.result() + total_cand += n_cand + total_kept += n_kept + tag = "DRY " if args.dry_run else "" + print(f"{tag}{f}: {n_kept}/{n_cand}" + (f" ERR {err}" if err else "")) + else: + for w in work: + f, (n_cand, n_kept), err = _worker(w) + total_cand += n_cand + total_kept += n_kept + tag = "DRY " if args.dry_run else "" + print(f"{tag}{f}: {n_kept}/{n_cand}" + (f" ERR {err}" if err else "")) + + print(f"# total: kept {total_kept} / {total_cand} candidate edit(s) " + f"across {len(files)} file(s)") + + +if __name__ == "__main__": + main() From b301914a470a0332700deaa3071906c00bcc8d6c Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Sun, 24 May 2026 17:54:59 +0200 Subject: [PATCH 03/30] more --- Mathlib/Algebra/Category/CoalgCat/Monoidal.lean | 2 +- Mathlib/Algebra/Category/Grp/Preadditive.lean | 2 +- Mathlib/Algebra/Category/ModuleCat/Basic.lean | 4 ++-- Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean | 2 +- Mathlib/Algebra/Category/ModuleCat/Semi.lean | 4 ++-- Mathlib/Algebra/Order/CauSeq/Basic.lean | 4 ++-- Mathlib/Algebra/Order/Nonneg/Ring.lean | 2 +- Mathlib/Algebra/Ring/Subsemiring/Basic.lean | 2 +- Mathlib/Algebra/Star/NonUnitalSubalgebra.lean | 2 +- Mathlib/CategoryTheory/Abelian/Basic.lean | 4 ++-- Mathlib/CategoryTheory/Abelian/NonPreadditive.lean | 2 +- Mathlib/CategoryTheory/Galois/Topology.lean | 2 +- Mathlib/CategoryTheory/MorphismProperty/Limits.lean | 2 +- Mathlib/CategoryTheory/ObjectProperty/Shift.lean | 2 +- Mathlib/CategoryTheory/Shift/Quotient.lean | 2 +- Mathlib/CategoryTheory/Sites/Precoverage.lean | 2 +- Mathlib/CategoryTheory/Subfunctor/Basic.lean | 2 +- 17 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Mathlib/Algebra/Category/CoalgCat/Monoidal.lean b/Mathlib/Algebra/Category/CoalgCat/Monoidal.lean index 5de663767ebe38..0e2468108d2e06 100644 --- a/Mathlib/Algebra/Category/CoalgCat/Monoidal.lean +++ b/Mathlib/Algebra/Category/CoalgCat/Monoidal.lean @@ -61,6 +61,6 @@ noncomputable def MonoidalCategory.inducingFunctorData : rightUnitor_eq X := ModuleCat.hom_ext <| TensorProduct.ext <| by ext; rfl noncomputable instance instMonoidalCategory : MonoidalCategory (CoalgCat R) := - Monoidal.induced (forget₂ _ (ModuleCat R)) (MonoidalCategory.inducingFunctorData R) + fast_instance% Monoidal.induced (forget₂ _ (ModuleCat R)) (MonoidalCategory.inducingFunctorData R) end CoalgCat diff --git a/Mathlib/Algebra/Category/Grp/Preadditive.lean b/Mathlib/Algebra/Category/Grp/Preadditive.lean index ccedfff6c22775..8026bb2bcf8080 100644 --- a/Mathlib/Algebra/Category/Grp/Preadditive.lean +++ b/Mathlib/Algebra/Category/Grp/Preadditive.lean @@ -57,7 +57,7 @@ instance : SMul ℤ (M ⟶ N) where @[simp] lemma hom_zsmul (n : ℤ) (f : M ⟶ N) : (n • f).hom = n • f.hom := rfl instance (P Q : AddCommGrpCat) : AddCommGroup (P ⟶ Q) := - Function.Injective.addCommGroup (Hom.hom) ConcreteCategory.hom_injective + fast_instance% Function.Injective.addCommGroup (Hom.hom) ConcreteCategory.hom_injective rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance : Preadditive AddCommGrpCat where diff --git a/Mathlib/Algebra/Category/ModuleCat/Basic.lean b/Mathlib/Algebra/Category/ModuleCat/Basic.lean index d4d14bdef164ea..92d7a260fbe980 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Basic.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Basic.lean @@ -354,7 +354,7 @@ instance : SMul ℤ (M ⟶ N) where @[simp] lemma hom_zsmul (n : ℤ) (f : M ⟶ N) : (n • f).hom = n • f.hom := rfl instance : AddCommGroup (M ⟶ N) := - Function.Injective.addCommGroup (Hom.hom) hom_injective + fast_instance% Function.Injective.addCommGroup (Hom.hom) hom_injective rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) @[simp] lemma hom_sum {ι : Type*} (f : ι → (M ⟶ N)) (s : Finset ι) : @@ -406,7 +406,7 @@ section Module variable {M N : ModuleCat.{v} R} {S : Type*} [Semiring S] [Module S N] [SMulCommClass R S N] instance Hom.instModule : Module S (M ⟶ N) := - Function.Injective.module S + fast_instance% Function.Injective.module S { toFun := Hom.hom, map_zero' := hom_zero, map_add' := hom_add } hom_injective (fun _ _ => rfl) diff --git a/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean b/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean index 198649299c8421..f33246f0512e5d 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean @@ -308,7 +308,7 @@ instance MonoidalCategory.instMonoidalCategoryStruct : rightUnitor M := (TensorProduct.rid R M).toModuleIso instance monoidalCategory : MonoidalCategory (ModuleCat.{u} R) := - Monoidal.induced equivalenceSemimoduleCat.functor + fast_instance% Monoidal.induced equivalenceSemimoduleCat.functor { μIso _ _ := .refl _ εIso := .refl _ associator_eq _ _ _ := by ext1; exact TensorProduct.ext (TensorProduct.ext rfl) diff --git a/Mathlib/Algebra/Category/ModuleCat/Semi.lean b/Mathlib/Algebra/Category/ModuleCat/Semi.lean index 951b0e0834a109..9dbaa1878a21bc 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Semi.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Semi.lean @@ -305,7 +305,7 @@ instance : SMul ℕ (M ⟶ N) where alias hom_zsmul := hom_nsmul instance : AddCommMonoid (M ⟶ N) := - Function.Injective.addCommMonoid Hom.hom hom_injective rfl (fun _ _ => rfl) (fun _ _ => rfl) + fast_instance% Function.Injective.addCommMonoid Hom.hom hom_injective rfl (fun _ _ => rfl) (fun _ _ => rfl) @[simp] lemma hom_sum {ι : Type*} (f : ι → (M ⟶ N)) (s : Finset ι) : (∑ i ∈ s, f i).hom = ∑ i ∈ s, (f i).hom := @@ -356,7 +356,7 @@ section Module variable {M N : SemimoduleCat.{v} R} {S : Type*} [Semiring S] [Module S N] [SMulCommClass R S N] instance Hom.instModule : Module S (M ⟶ N) := - Function.Injective.module S + fast_instance% Function.Injective.module S { toFun := Hom.hom, map_zero' := hom_zero, map_add' := hom_add } hom_injective (fun _ _ => rfl) diff --git a/Mathlib/Algebra/Order/CauSeq/Basic.lean b/Mathlib/Algebra/Order/CauSeq/Basic.lean index dbdf5522c12676..6bb545e7d08bd4 100644 --- a/Mathlib/Algebra/Order/CauSeq/Basic.lean +++ b/Mathlib/Algebra/Order/CauSeq/Basic.lean @@ -332,7 +332,7 @@ instance instNatCast : NatCast (CauSeq β abv) := ⟨fun n => const n⟩ instance instIntCast : IntCast (CauSeq β abv) := ⟨fun n => const n⟩ instance addGroupWithOne : AddGroupWithOne (CauSeq β abv) := - Function.Injective.addGroupWithOne Subtype.val Subtype.val_injective rfl rfl + fast_instance% Function.Injective.addGroupWithOne Subtype.val Subtype.val_injective rfl rfl coe_add coe_neg coe_sub (by intros; rfl) (by intros; rfl) @@ -355,7 +355,7 @@ theorem const_pow (x : β) (n : ℕ) : const (x ^ n) = const x ^ n := rfl instance ring : Ring (CauSeq β abv) := - Function.Injective.ring Subtype.val Subtype.val_injective rfl rfl coe_add coe_mul coe_neg coe_sub + fast_instance% Function.Injective.ring Subtype.val Subtype.val_injective rfl rfl coe_add coe_mul coe_neg coe_sub (fun _ _ => coe_smul _ _) (fun _ _ => coe_smul _ _) coe_pow (fun _ => rfl) fun _ => rfl instance {β : Type*} [CommRing β] {abv : β → α} [IsAbsoluteValue abv] : CommRing (CauSeq β abv) := diff --git a/Mathlib/Algebra/Order/Nonneg/Ring.lean b/Mathlib/Algebra/Order/Nonneg/Ring.lean index ed108e156af298..3a34a803638f25 100644 --- a/Mathlib/Algebra/Order/Nonneg/Ring.lean +++ b/Mathlib/Algebra/Order/Nonneg/Ring.lean @@ -50,7 +50,7 @@ instance isOrderedAddMonoid [AddCommMonoid α] [PartialOrder α] [IsOrderedAddMo instance isOrderedCancelAddMonoid [AddCommMonoid α] [PartialOrder α] [IsOrderedCancelAddMonoid α] : IsOrderedCancelAddMonoid { x : α // 0 ≤ x } := - fast_instance% Function.Injective.isOrderedCancelAddMonoid _ Nonneg.coe_add .rfl + Function.Injective.isOrderedCancelAddMonoid _ Nonneg.coe_add .rfl instance isOrderedRing [Semiring α] [PartialOrder α] [IsOrderedRing α] : IsOrderedRing { x : α // 0 ≤ x } := diff --git a/Mathlib/Algebra/Ring/Subsemiring/Basic.lean b/Mathlib/Algebra/Ring/Subsemiring/Basic.lean index d3a7ab89c659ad..7e9b9150b35264 100644 --- a/Mathlib/Algebra/Ring/Subsemiring/Basic.lean +++ b/Mathlib/Algebra/Ring/Subsemiring/Basic.lean @@ -35,7 +35,7 @@ variable [SetLike S R] [hSR : SubsemiringClass S R] (s : S) namespace SubsemiringClass instance instCharZero [CharZero R] : CharZero s := - ⟨Function.Injective.of_comp (f := Subtype.val) (g := Nat.cast (R := s)) Nat.cast_injective⟩ + fast_instance% ⟨Function.Injective.of_comp (f := Subtype.val) (g := Nat.cast (R := s)) Nat.cast_injective⟩ end SubsemiringClass diff --git a/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean b/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean index 9811d392d794a9..74e8b6544b458d 100644 --- a/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean +++ b/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean @@ -300,7 +300,7 @@ instance instSMulCommClass [SMulCommClass R A A] : SMulCommClass R S S where end instance instIsTorsionFree [IsTorsionFree R A] : IsTorsionFree R S := - fast_instance% Subtype.coe_injective.moduleIsTorsionFree _ (by simp) + Subtype.coe_injective.moduleIsTorsionFree _ (by simp) protected theorem coe_add (x y : S) : (↑(x + y) : A) = ↑x + ↑y := rfl diff --git a/Mathlib/CategoryTheory/Abelian/Basic.lean b/Mathlib/CategoryTheory/Abelian/Basic.lean index 9f7d3225a75779..3a5b9159bebe86 100644 --- a/Mathlib/CategoryTheory/Abelian/Basic.lean +++ b/Mathlib/CategoryTheory/Abelian/Basic.lean @@ -738,7 +738,7 @@ variable [Limits.HasPushouts C] {W X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) set_option backward.isDefEq.respectTransparency false in instance mono_pushout_of_mono_f [Mono f] : Mono (pushout.inr _ _ : Z ⟶ pushout f g) := - mono_of_cancel_zero _ fun {R} e h => by + fast_instance% mono_of_cancel_zero _ fun {R} e h => by let u := biprod.lift (0 : R ⟶ Y) e have hu : u ≫ BiproductToPushoutIsCokernel.biproductToPushout f g = 0 := by simpa [u] have := @@ -761,7 +761,7 @@ instance mono_pushout_of_mono_f [Mono f] : Mono (pushout.inr _ _ : Z ⟶ pushout set_option backward.isDefEq.respectTransparency false in instance mono_pushout_of_mono_g [Mono g] : Mono (pushout.inl f g) := - mono_of_cancel_zero _ fun {R} e h => by + fast_instance% mono_of_cancel_zero _ fun {R} e h => by let u := biprod.lift e (0 : R ⟶ Z) have hu : u ≫ BiproductToPushoutIsCokernel.biproductToPushout f g = 0 := by simpa [u] have := diff --git a/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean b/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean index 21e1139fae40f8..03da7309e92556 100644 --- a/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean +++ b/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean @@ -146,7 +146,7 @@ instance isIso_factorThruImage [Mono f] : IsIso (Abelian.factorThruImage f) := /-- The canonical morphism `i : coimage f ⟶ Q` is a monomorphism -/ instance : Mono (Abelian.factorThruCoimage f) := - let I := Abelian.coimage f + fast_instance% let I := Abelian.coimage f let i := Abelian.factorThruCoimage f let p := cokernel.π (kernel.ι f) NormalEpiCategory.mono_of_cancel_zero _ fun R (g : R ⟶ I) (hgi : g ≫ i = 0) => by diff --git a/Mathlib/CategoryTheory/Galois/Topology.lean b/Mathlib/CategoryTheory/Galois/Topology.lean index b3075869aaa53e..590acd03b942fe 100644 --- a/Mathlib/CategoryTheory/Galois/Topology.lean +++ b/Mathlib/CategoryTheory/Galois/Topology.lean @@ -75,7 +75,7 @@ lemma aut_discreteTopology (X : C) : DiscreteTopology (Aut (F.obj X)) := ⟨rfl /-- `Aut F` is equipped with the by the embedding into `∀ X, Aut (F.obj X)` induced embedding. -/ instance : TopologicalSpace (Aut F) := - TopologicalSpace.induced (autEmbedding F) inferInstance + fast_instance% TopologicalSpace.induced (autEmbedding F) inferInstance /-lemma autEmbedding_range : Set.range (autEmbedding F) = diff --git a/Mathlib/CategoryTheory/MorphismProperty/Limits.lean b/Mathlib/CategoryTheory/MorphismProperty/Limits.lean index 9f5b8452764f34..671a7835398f3b 100644 --- a/Mathlib/CategoryTheory/MorphismProperty/Limits.lean +++ b/Mathlib/CategoryTheory/MorphismProperty/Limits.lean @@ -446,7 +446,7 @@ lemma limitsOfShape_monotone {W₁ W₂ : MorphismProperty C} (h : W₁ ≤ W₂ set_option backward.isDefEq.respectTransparency false in instance : (W.limitsOfShape J).RespectsIso := - RespectsIso.of_respects_arrow_iso _ (by + fast_instance% RespectsIso.of_respects_arrow_iso _ (by rintro ⟨_, _, f⟩ ⟨Y₁, Y₂, g⟩ e ⟨X₁, X₂, c₁, c₂, h₁, h₂, f, hf⟩ let e₁ := Arrow.leftFunc.mapIso e let e₂ := Arrow.rightFunc.mapIso e diff --git a/Mathlib/CategoryTheory/ObjectProperty/Shift.lean b/Mathlib/CategoryTheory/ObjectProperty/Shift.lean index b08036902eb037..85c932d1205b0e 100644 --- a/Mathlib/CategoryTheory/ObjectProperty/Shift.lean +++ b/Mathlib/CategoryTheory/ObjectProperty/Shift.lean @@ -193,7 +193,7 @@ variable [P.IsStableUnderShift A] noncomputable instance hasShift : HasShift P.FullSubcategory A := - P.fullyFaithfulι.hasShift (fun n ↦ ObjectProperty.lift _ (P.ι ⋙ shiftFunctor C n) + fast_instance% P.fullyFaithfulι.hasShift (fun n ↦ ObjectProperty.lift _ (P.ι ⋙ shiftFunctor C n) (fun X ↦ P.le_shift n _ X.2)) (fun _ => P.liftCompιIso _ _) instance commShiftι : P.ι.CommShift A := diff --git a/Mathlib/CategoryTheory/Shift/Quotient.lean b/Mathlib/CategoryTheory/Shift/Quotient.lean index 72e262773c78d1..e48d7facbf53ae 100644 --- a/Mathlib/CategoryTheory/Shift/Quotient.lean +++ b/Mathlib/CategoryTheory/Shift/Quotient.lean @@ -48,7 +48,7 @@ namespace CategoryTheory relation `r` is compatible with the shift. -/ noncomputable instance HasShift.quotient [r.IsCompatibleWithShift A] : HasShift (Quotient r) A := - HasShift.induced (Quotient.functor r) A + fast_instance% HasShift.induced (Quotient.functor r) A (fun a => Quotient.lift r (shiftFunctor C a ⋙ Quotient.functor r) (fun _ _ _ _ hfg => Quotient.sound r (HomRel.IsCompatibleWithShift.condition _ _ _ hfg))) (fun _ => Quotient.lift.isLift _ _ _) diff --git a/Mathlib/CategoryTheory/Sites/Precoverage.lean b/Mathlib/CategoryTheory/Sites/Precoverage.lean index b0273725c31be0..4c41e60baa985e 100644 --- a/Mathlib/CategoryTheory/Sites/Precoverage.lean +++ b/Mathlib/CategoryTheory/Sites/Precoverage.lean @@ -80,7 +80,7 @@ instance : Bot (Precoverage C) where bot.coverings _ := ∅ instance : CompleteLattice (Precoverage C) := - Function.Injective.completeLattice Precoverage.coverings (fun _ _ hab ↦ Precoverage.ext hab) + fast_instance% Function.Injective.completeLattice Precoverage.coverings (fun _ _ hab ↦ Precoverage.ext hab) .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) rfl rfl /-- A precoverage has isomorphisms if singleton presieves by isomorphisms are covering. -/ diff --git a/Mathlib/CategoryTheory/Subfunctor/Basic.lean b/Mathlib/CategoryTheory/Subfunctor/Basic.lean index 741777bea72237..ef8f65f6381f08 100644 --- a/Mathlib/CategoryTheory/Subfunctor/Basic.lean +++ b/Mathlib/CategoryTheory/Subfunctor/Basic.lean @@ -48,7 +48,7 @@ structure Subfunctor (F : C ⥤ Type w) where variable {F F' F'' : C ⥤ Type w} (G G' : Subfunctor F) instance : PartialOrder (Subfunctor F) := - PartialOrder.lift Subfunctor.obj (fun _ _ => Subfunctor.ext) + fast_instance% PartialOrder.lift Subfunctor.obj (fun _ _ => Subfunctor.ext) instance : CompleteLattice (Subfunctor F) where sup F G := From 7a4992469d3d960257dc9f676f6ec8b3172a1e0b Mon Sep 17 00:00:00 2001 From: Kevin Buzzard Date: Sun, 24 May 2026 21:11:03 +0100 Subject: [PATCH 04/30] fix build --- Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean b/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean index f33246f0512e5d..198649299c8421 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean @@ -308,7 +308,7 @@ instance MonoidalCategory.instMonoidalCategoryStruct : rightUnitor M := (TensorProduct.rid R M).toModuleIso instance monoidalCategory : MonoidalCategory (ModuleCat.{u} R) := - fast_instance% Monoidal.induced equivalenceSemimoduleCat.functor + Monoidal.induced equivalenceSemimoduleCat.functor { μIso _ _ := .refl _ εIso := .refl _ associator_eq _ _ _ := by ext1; exact TensorProduct.ext (TensorProduct.ext rfl) From 6fcab5d9dedd49174a3a67f71e7acd2df9513cff Mon Sep 17 00:00:00 2001 From: Kevin Buzzard Date: Sun, 24 May 2026 21:20:46 +0100 Subject: [PATCH 05/30] fix line-length lints and drop fast_instance% from proof-instances --- Mathlib/Algebra/AddConstMap/Basic.lean | 3 +- Mathlib/Algebra/Category/ModuleCat/Semi.lean | 3 +- Mathlib/Algebra/DirectSum/Ring.lean | 31 ++++++++++--------- Mathlib/Algebra/GradedMonoid.lean | 3 +- Mathlib/Algebra/Group/ULift.lean | 8 ++--- Mathlib/Algebra/GroupWithZero/ULift.lean | 8 ++--- Mathlib/Algebra/Module/Torsion/Basic.lean | 4 +-- Mathlib/Algebra/Order/CauSeq/Basic.lean | 9 +++--- Mathlib/Algebra/Ring/Subsemiring/Basic.lean | 3 +- Mathlib/Algebra/Star/SelfAdjoint.lean | 10 +++--- Mathlib/Algebra/Symmetrized.lean | 3 +- Mathlib/CategoryTheory/Abelian/Basic.lean | 4 +-- .../Abelian/NonPreadditive.lean | 2 +- .../MorphismProperty/Limits.lean | 2 +- Mathlib/CategoryTheory/Sites/Precoverage.lean | 3 +- Mathlib/Data/FinEnum.lean | 3 +- Mathlib/FieldTheory/PerfectClosure.lean | 3 +- Mathlib/Order/BooleanSubalgebra.lean | 4 +-- Mathlib/Order/OmegaCompletePartialOrder.lean | 3 +- 19 files changed, 62 insertions(+), 47 deletions(-) diff --git a/Mathlib/Algebra/AddConstMap/Basic.lean b/Mathlib/Algebra/AddConstMap/Basic.lean index 1b2eadf3abbe2a..8ea5d0643cf6c9 100644 --- a/Mathlib/Algebra/AddConstMap/Basic.lean +++ b/Mathlib/Algebra/AddConstMap/Basic.lean @@ -391,7 +391,8 @@ instance : Pow (G →+c[a, a] G) ℕ where pow f n := ⟨f^[n], Commute.iterate_left (AddConstMapClass.semiconj f) _⟩ instance : Monoid (G →+c[a, a] G) := - fast_instance% DFunLike.coe_injective.monoid (M₂ := Function.End G) _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.monoid (M₂ := Function.End G) _ rfl (fun _ _ ↦ rfl) + fun _ _ ↦ rfl theorem mul_def (f g : G →+c[a, a] G) : f * g = f.comp g := rfl @[simp, push_cast] theorem coe_mul (f g : G →+c[a, a] G) : ⇑(f * g) = f ∘ g := rfl diff --git a/Mathlib/Algebra/Category/ModuleCat/Semi.lean b/Mathlib/Algebra/Category/ModuleCat/Semi.lean index 9dbaa1878a21bc..1a67b2abacfdf6 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Semi.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Semi.lean @@ -305,7 +305,8 @@ instance : SMul ℕ (M ⟶ N) where alias hom_zsmul := hom_nsmul instance : AddCommMonoid (M ⟶ N) := - fast_instance% Function.Injective.addCommMonoid Hom.hom hom_injective rfl (fun _ _ => rfl) (fun _ _ => rfl) + fast_instance% Function.Injective.addCommMonoid Hom.hom hom_injective rfl (fun _ _ => rfl) + (fun _ _ => rfl) @[simp] lemma hom_sum {ι : Type*} (f : ι → (M ⟶ N)) (s : Finset ι) : (∑ i ∈ s, f i).hom = ∑ i ∈ s, (f i).hom := diff --git a/Mathlib/Algebra/DirectSum/Ring.lean b/Mathlib/Algebra/DirectSum/Ring.lean index 3d440d3dec426e..4d66ba4327847e 100644 --- a/Mathlib/Algebra/DirectSum/Ring.lean +++ b/Mathlib/Algebra/DirectSum/Ring.lean @@ -383,8 +383,8 @@ theorem of_zero_mul (a b : A 0) : of _ 0 (a * b) = of _ 0 a * of _ 0 b := of_zero_smul A a b instance (priority := 900) GradeZero.nonUnitalNonAssocSemiring : NonUnitalNonAssocSemiring (A 0) := - fast_instance% Function.Injective.nonUnitalNonAssocSemiring (of A 0) DFinsupp.single_injective (of A 0).map_zero - (of A 0).map_add (of_zero_mul A) (map_nsmul _) + fast_instance% Function.Injective.nonUnitalNonAssocSemiring (of A 0) DFinsupp.single_injective + (of A 0).map_zero (of A 0).map_add (of_zero_mul A) (map_nsmul _) instance GradeZero.smulWithZero (i : ι) : SMulWithZero (A 0) (A i) := by letI := SMulWithZero.compHom (⨁ i, A i) (of A 0).toZeroHom @@ -419,8 +419,8 @@ theorem of_zero_ofNat (n : ℕ) [n.AtLeastTwo] : of A 0 ofNat(n) = ofNat(n) := /-- The `Semiring` structure derived from `GSemiring A`. -/ instance (priority := 900) GradeZero.semiring : Semiring (A 0) := - fast_instance% Function.Injective.semiring (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A) - (of A 0).map_add (of_zero_mul A) (fun _ _ ↦ (of A 0).map_nsmul _ _) + fast_instance% Function.Injective.semiring (of A 0) DFinsupp.single_injective (of A 0).map_zero + (of_zero_one A) (of A 0).map_add (of_zero_mul A) (fun _ _ ↦ (of A 0).map_nsmul _ _) (fun _ _ => of_zero_pow _ _ _) (of_natCast A) /-- `of A 0` is a `RingHom`, using the `DirectSum.GradeZero.semiring` structure. -/ @@ -444,8 +444,8 @@ variable [∀ i, AddCommMonoid (A i)] [AddCommMonoid ι] [GCommSemiring A] /-- The `CommSemiring` structure derived from `GCommSemiring A`. -/ instance (priority := 900) GradeZero.commSemiring : CommSemiring (A 0) := - fast_instance% Function.Injective.commSemiring (of A 0) DFinsupp.single_injective (of A 0).map_zero - (of_zero_one A) (of A 0).map_add (of_zero_mul A) (fun _ _ ↦ map_nsmul _ _ _) + fast_instance% Function.Injective.commSemiring (of A 0) DFinsupp.single_injective + (of A 0).map_zero (of_zero_one A) (of A 0).map_add (of_zero_mul A) (fun _ _ ↦ map_nsmul _ _ _) (fun _ _ => of_zero_pow _ _ _) (of_natCast A) end CommSemiring @@ -456,8 +456,9 @@ variable [∀ i, AddCommGroup (A i)] [AddZeroClass ι] [GNonUnitalNonAssocSemiri /-- The `NonUnitalNonAssocRing` derived from `GNonUnitalNonAssocSemiring A`. -/ instance (priority := 900) GradeZero.nonUnitalNonAssocRing : NonUnitalNonAssocRing (A 0) := - fast_instance% Function.Injective.nonUnitalNonAssocRing (of A 0) DFinsupp.single_injective (of A 0).map_zero - (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_nsmul _ _ _) + fast_instance% Function.Injective.nonUnitalNonAssocRing (of A 0) DFinsupp.single_injective + (of A 0).map_zero (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub + (fun _ _ ↦ map_nsmul _ _ _) (fun _ _ ↦ map_zsmul _ _ _) end Ring @@ -475,9 +476,10 @@ theorem of_intCast (n : ℤ) : of A 0 n = n := by /-- The `Ring` derived from `GSemiring A`. -/ instance (priority := 900) GradeZero.ring : Ring (A 0) := - fast_instance% Function.Injective.ring (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A) - (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_nsmul _ _ _) - (fun _ _ ↦ map_zsmul _ _ _) (fun _ _ => of_zero_pow _ _ _) (of_natCast A) (of_intCast A) + fast_instance% Function.Injective.ring (of A 0) DFinsupp.single_injective (of A 0).map_zero + (of_zero_one A) (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub + (fun _ _ ↦ map_nsmul _ _ _) (fun _ _ ↦ map_zsmul _ _ _) (fun _ _ => of_zero_pow _ _ _) + (of_natCast A) (of_intCast A) end Ring @@ -487,9 +489,10 @@ variable [∀ i, AddCommGroup (A i)] [AddCommMonoid ι] [GCommRing A] /-- The `CommRing` derived from `GCommSemiring A`. -/ instance (priority := 900) GradeZero.commRing : CommRing (A 0) := - fast_instance% Function.Injective.commRing (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A) - (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_nsmul _ _ _) - (fun _ _ ↦ map_zsmul _ _ _) (fun _ _ => of_zero_pow _ _ _) (of_natCast A) (of_intCast A) + fast_instance% Function.Injective.commRing (of A 0) DFinsupp.single_injective (of A 0).map_zero + (of_zero_one A) (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub + (fun _ _ ↦ map_nsmul _ _ _) (fun _ _ ↦ map_zsmul _ _ _) (fun _ _ => of_zero_pow _ _ _) + (of_natCast A) (of_intCast A) end CommRing diff --git a/Mathlib/Algebra/GradedMonoid.lean b/Mathlib/Algebra/GradedMonoid.lean index dc3758ab9eb627..410c1622f1a806 100644 --- a/Mathlib/Algebra/GradedMonoid.lean +++ b/Mathlib/Algebra/GradedMonoid.lean @@ -337,7 +337,8 @@ variable [AddCommMonoid ι] [GCommMonoid A] /-- The `CommMonoid` structure derived from `GCommMonoid A`. -/ instance (priority := 900) GradeZero.commMonoid : CommMonoid (A 0) := - fast_instance% Function.Injective.commMonoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow + fast_instance% Function.Injective.commMonoid (mk 0) sigma_mk_injective rfl mk_zero_smul + mk_zero_pow end Monoid diff --git a/Mathlib/Algebra/Group/ULift.lean b/Mathlib/Algebra/Group/ULift.lean index 58e68008f8812e..60454a6cf1a0af 100644 --- a/Mathlib/Algebra/Group/ULift.lean +++ b/Mathlib/Algebra/Group/ULift.lean @@ -97,8 +97,8 @@ instance commMonoid [CommMonoid α] : CommMonoid (ULift α) := @[to_additive] instance divInvMonoid [DivInvMonoid α] : DivInvMonoid (ULift α) := - fast_instance% Equiv.ulift.injective.divInvMonoid _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) - (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.divInvMonoid _ rfl (fun _ _ => rfl) (fun _ => rfl) + (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance group [Group α] : Group (ULift α) := @@ -107,8 +107,8 @@ instance group [Group α] : Group (ULift α) := @[to_additive] instance commGroup [CommGroup α] : CommGroup (ULift α) := - fast_instance% Equiv.ulift.injective.commGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) - (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.commGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) + (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance leftCancelSemigroup [LeftCancelSemigroup α] : LeftCancelSemigroup (ULift α) := diff --git a/Mathlib/Algebra/GroupWithZero/ULift.lean b/Mathlib/Algebra/GroupWithZero/ULift.lean index 92eb5353683195..eeeae35b9c4fef 100644 --- a/Mathlib/Algebra/GroupWithZero/ULift.lean +++ b/Mathlib/Algebra/GroupWithZero/ULift.lean @@ -37,11 +37,11 @@ instance commMonoidWithZero [CommMonoidWithZero α] : CommMonoidWithZero (ULift fast_instance% Equiv.ulift.injective.commMonoidWithZero _ rfl rfl (fun _ _ => rfl) fun _ _ => rfl instance groupWithZero [GroupWithZero α] : GroupWithZero (ULift α) := - fast_instance% Equiv.ulift.injective.groupWithZero _ rfl rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) - (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.groupWithZero _ rfl rfl (fun _ _ => rfl) (fun _ => rfl) + (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl instance commGroupWithZero [CommGroupWithZero α] : CommGroupWithZero (ULift α) := - fast_instance% Equiv.ulift.injective.commGroupWithZero _ rfl rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) - (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Equiv.ulift.injective.commGroupWithZero _ rfl rfl (fun _ _ => rfl) (fun _ => rfl) + (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl end ULift diff --git a/Mathlib/Algebra/Module/Torsion/Basic.lean b/Mathlib/Algebra/Module/Torsion/Basic.lean index 87f1ee40805c67..bc0fc616fa9c5a 100644 --- a/Mathlib/Algebra/Module/Torsion/Basic.lean +++ b/Mathlib/Algebra/Module/Torsion/Basic.lean @@ -759,8 +759,8 @@ instance : SMul S (torsion' R M S) := rw [smul_comm, h, smul_zero]⟩⟩ instance : DistribMulAction S (torsion' R M S) := - fast_instance% Subtype.coe_injective.distribMulAction (torsion' R M S).subtype.toAddMonoidHom fun (_ : S) _ => - rfl + fast_instance% Subtype.coe_injective.distribMulAction (torsion' R M S).subtype.toAddMonoidHom + fun (_ : S) _ => rfl instance : SMulCommClass S R (torsion' R M S) := ⟨fun _ _ _ => Subtype.ext <| smul_comm _ _ _⟩ diff --git a/Mathlib/Algebra/Order/CauSeq/Basic.lean b/Mathlib/Algebra/Order/CauSeq/Basic.lean index 6bb545e7d08bd4..4ee5163e863edd 100644 --- a/Mathlib/Algebra/Order/CauSeq/Basic.lean +++ b/Mathlib/Algebra/Order/CauSeq/Basic.lean @@ -324,8 +324,8 @@ instance : IsScalarTower G (CauSeq β abv) (CauSeq β abv) := end SMul instance addGroup : AddGroup (CauSeq β abv) := - fast_instance% Function.Injective.addGroup Subtype.val Subtype.val_injective rfl coe_add coe_neg coe_sub - (fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _ + fast_instance% Function.Injective.addGroup Subtype.val Subtype.val_injective rfl coe_add coe_neg + coe_sub (fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _ instance instNatCast : NatCast (CauSeq β abv) := ⟨fun n => const n⟩ @@ -355,8 +355,9 @@ theorem const_pow (x : β) (n : ℕ) : const (x ^ n) = const x ^ n := rfl instance ring : Ring (CauSeq β abv) := - fast_instance% Function.Injective.ring Subtype.val Subtype.val_injective rfl rfl coe_add coe_mul coe_neg coe_sub - (fun _ _ => coe_smul _ _) (fun _ _ => coe_smul _ _) coe_pow (fun _ => rfl) fun _ => rfl + fast_instance% Function.Injective.ring Subtype.val Subtype.val_injective rfl rfl coe_add coe_mul + coe_neg coe_sub (fun _ _ => coe_smul _ _) (fun _ _ => coe_smul _ _) coe_pow (fun _ => rfl) + fun _ => rfl instance {β : Type*} [CommRing β] {abv : β → α} [IsAbsoluteValue abv] : CommRing (CauSeq β abv) := { CauSeq.ring with diff --git a/Mathlib/Algebra/Ring/Subsemiring/Basic.lean b/Mathlib/Algebra/Ring/Subsemiring/Basic.lean index 7e9b9150b35264..5b266f4c8eb7ee 100644 --- a/Mathlib/Algebra/Ring/Subsemiring/Basic.lean +++ b/Mathlib/Algebra/Ring/Subsemiring/Basic.lean @@ -35,7 +35,8 @@ variable [SetLike S R] [hSR : SubsemiringClass S R] (s : S) namespace SubsemiringClass instance instCharZero [CharZero R] : CharZero s := - fast_instance% ⟨Function.Injective.of_comp (f := Subtype.val) (g := Nat.cast (R := s)) Nat.cast_injective⟩ + fast_instance% ⟨Function.Injective.of_comp (f := Subtype.val) (g := Nat.cast (R := s)) + Nat.cast_injective⟩ end SubsemiringClass diff --git a/Mathlib/Algebra/Star/SelfAdjoint.lean b/Mathlib/Algebra/Star/SelfAdjoint.lean index 52a02683e4c4c4..6c3c353f91014a 100644 --- a/Mathlib/Algebra/Star/SelfAdjoint.lean +++ b/Mathlib/Algebra/Star/SelfAdjoint.lean @@ -439,8 +439,8 @@ section CommRing variable [CommRing R] [StarRing R] instance : CommRing (selfAdjoint R) := - fast_instance% Function.Injective.commRing _ Subtype.coe_injective (selfAdjoint R).coe_zero val_one - (selfAdjoint R).coe_add val_mul (selfAdjoint R).coe_neg (selfAdjoint R).coe_sub + fast_instance% Function.Injective.commRing _ Subtype.coe_injective (selfAdjoint R).coe_zero + val_one (selfAdjoint R).coe_add val_mul (selfAdjoint R).coe_neg (selfAdjoint R).coe_sub (by intros; rfl) (by intros; rfl) val_pow (fun _ => rfl) fun _ => rfl @@ -512,7 +512,8 @@ instance [Monoid R] [MulAction R A] [StarModule R A] : MulAction R (selfAdjoint fast_instance% Function.Injective.mulAction Subtype.val Subtype.coe_injective val_smul instance [Monoid R] [DistribMulAction R A] [StarModule R A] : DistribMulAction R (selfAdjoint A) := - fast_instance% Function.Injective.distribMulAction (selfAdjoint A).subtype Subtype.coe_injective val_smul + fast_instance% Function.Injective.distribMulAction (selfAdjoint A).subtype + Subtype.coe_injective val_smul end SMul @@ -584,7 +585,8 @@ theorem val_smul [Monoid R] [DistribMulAction R A] [StarModule R A] (r : R) (x : rfl instance [Monoid R] [DistribMulAction R A] [StarModule R A] : DistribMulAction R (skewAdjoint A) := - fast_instance% Function.Injective.distribMulAction (skewAdjoint A).subtype Subtype.coe_injective val_smul + fast_instance% Function.Injective.distribMulAction (skewAdjoint A).subtype + Subtype.coe_injective val_smul instance [Semiring R] [Module R A] [StarModule R A] : Module R (skewAdjoint A) := fast_instance% Function.Injective.module R (skewAdjoint A).subtype Subtype.coe_injective val_smul diff --git a/Mathlib/Algebra/Symmetrized.lean b/Mathlib/Algebra/Symmetrized.lean index df8dc05be008b8..a0cb52e938fadd 100644 --- a/Mathlib/Algebra/Symmetrized.lean +++ b/Mathlib/Algebra/Symmetrized.lean @@ -234,7 +234,8 @@ instance addCommGroup [AddCommGroup α] : AddCommGroup αˢʸᵐ := { SymAlg.addCommMonoid, SymAlg.addGroup with } instance {R : Type*} [Semiring R] [AddCommMonoid α] [Module R α] : Module R αˢʸᵐ := - fast_instance% Function.Injective.module R ⟨⟨unsym, unsym_zero⟩, unsym_add⟩ unsym_injective unsym_smul + fast_instance% Function.Injective.module R ⟨⟨unsym, unsym_zero⟩, unsym_add⟩ unsym_injective + unsym_smul instance [Mul α] [AddMonoidWithOne α] [Invertible (2 : α)] (a : α) [Invertible a] : Invertible (sym a) where diff --git a/Mathlib/CategoryTheory/Abelian/Basic.lean b/Mathlib/CategoryTheory/Abelian/Basic.lean index 3a5b9159bebe86..9f7d3225a75779 100644 --- a/Mathlib/CategoryTheory/Abelian/Basic.lean +++ b/Mathlib/CategoryTheory/Abelian/Basic.lean @@ -738,7 +738,7 @@ variable [Limits.HasPushouts C] {W X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) set_option backward.isDefEq.respectTransparency false in instance mono_pushout_of_mono_f [Mono f] : Mono (pushout.inr _ _ : Z ⟶ pushout f g) := - fast_instance% mono_of_cancel_zero _ fun {R} e h => by + mono_of_cancel_zero _ fun {R} e h => by let u := biprod.lift (0 : R ⟶ Y) e have hu : u ≫ BiproductToPushoutIsCokernel.biproductToPushout f g = 0 := by simpa [u] have := @@ -761,7 +761,7 @@ instance mono_pushout_of_mono_f [Mono f] : Mono (pushout.inr _ _ : Z ⟶ pushout set_option backward.isDefEq.respectTransparency false in instance mono_pushout_of_mono_g [Mono g] : Mono (pushout.inl f g) := - fast_instance% mono_of_cancel_zero _ fun {R} e h => by + mono_of_cancel_zero _ fun {R} e h => by let u := biprod.lift e (0 : R ⟶ Z) have hu : u ≫ BiproductToPushoutIsCokernel.biproductToPushout f g = 0 := by simpa [u] have := diff --git a/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean b/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean index 03da7309e92556..21e1139fae40f8 100644 --- a/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean +++ b/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean @@ -146,7 +146,7 @@ instance isIso_factorThruImage [Mono f] : IsIso (Abelian.factorThruImage f) := /-- The canonical morphism `i : coimage f ⟶ Q` is a monomorphism -/ instance : Mono (Abelian.factorThruCoimage f) := - fast_instance% let I := Abelian.coimage f + let I := Abelian.coimage f let i := Abelian.factorThruCoimage f let p := cokernel.π (kernel.ι f) NormalEpiCategory.mono_of_cancel_zero _ fun R (g : R ⟶ I) (hgi : g ≫ i = 0) => by diff --git a/Mathlib/CategoryTheory/MorphismProperty/Limits.lean b/Mathlib/CategoryTheory/MorphismProperty/Limits.lean index 671a7835398f3b..9f5b8452764f34 100644 --- a/Mathlib/CategoryTheory/MorphismProperty/Limits.lean +++ b/Mathlib/CategoryTheory/MorphismProperty/Limits.lean @@ -446,7 +446,7 @@ lemma limitsOfShape_monotone {W₁ W₂ : MorphismProperty C} (h : W₁ ≤ W₂ set_option backward.isDefEq.respectTransparency false in instance : (W.limitsOfShape J).RespectsIso := - fast_instance% RespectsIso.of_respects_arrow_iso _ (by + RespectsIso.of_respects_arrow_iso _ (by rintro ⟨_, _, f⟩ ⟨Y₁, Y₂, g⟩ e ⟨X₁, X₂, c₁, c₂, h₁, h₂, f, hf⟩ let e₁ := Arrow.leftFunc.mapIso e let e₂ := Arrow.rightFunc.mapIso e diff --git a/Mathlib/CategoryTheory/Sites/Precoverage.lean b/Mathlib/CategoryTheory/Sites/Precoverage.lean index 4c41e60baa985e..90795f67274611 100644 --- a/Mathlib/CategoryTheory/Sites/Precoverage.lean +++ b/Mathlib/CategoryTheory/Sites/Precoverage.lean @@ -80,7 +80,8 @@ instance : Bot (Precoverage C) where bot.coverings _ := ∅ instance : CompleteLattice (Precoverage C) := - fast_instance% Function.Injective.completeLattice Precoverage.coverings (fun _ _ hab ↦ Precoverage.ext hab) + fast_instance% Function.Injective.completeLattice Precoverage.coverings + (fun _ _ hab ↦ Precoverage.ext hab) .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) rfl rfl /-- A precoverage has isomorphisms if singleton presieves by isomorphisms are covering. -/ diff --git a/Mathlib/Data/FinEnum.lean b/Mathlib/Data/FinEnum.lean index 94d27bc773b511..f4bf4486400f55 100644 --- a/Mathlib/Data/FinEnum.lean +++ b/Mathlib/Data/FinEnum.lean @@ -139,7 +139,8 @@ theorem card_fin {n} [FinEnum (Fin n)] : card (Fin n) = n := Fin.equiv_iff_eq.mp instance Quotient.enum [FinEnum α] (s : Setoid α) [DecidableRel ((· ≈ ·) : α → α → Prop)] : FinEnum (Quotient s) := - fast_instance% FinEnum.ofSurjective Quotient.mk'' fun x => Quotient.inductionOn x fun x => ⟨x, rfl⟩ + fast_instance% FinEnum.ofSurjective Quotient.mk'' fun x => + Quotient.inductionOn x fun x => ⟨x, rfl⟩ /-- enumerate all finite sets of a given type -/ def Finset.enum [DecidableEq α] : List α → List (Finset α) diff --git a/Mathlib/FieldTheory/PerfectClosure.lean b/Mathlib/FieldTheory/PerfectClosure.lean index dc5d042d3ce037..2759bce692ac86 100644 --- a/Mathlib/FieldTheory/PerfectClosure.lean +++ b/Mathlib/FieldTheory/PerfectClosure.lean @@ -471,7 +471,8 @@ section Field variable [Field K] (p : ℕ) [Fact p.Prime] [CharP K p] instance instInv : Inv (PerfectClosure K p) := - fast_instance% ⟨Quot.lift (fun x : ℕ × K => Quot.mk (R K p) (x.1, x.2⁻¹)) fun x y (H : R K p x y) => + fast_instance% ⟨Quot.lift (fun x : ℕ × K => Quot.mk (R K p) (x.1, x.2⁻¹)) + fun x y (H : R K p x y) => match x, y, H with | _, _, R.intro n x => Quot.sound <| by diff --git a/Mathlib/Order/BooleanSubalgebra.lean b/Mathlib/Order/BooleanSubalgebra.lean index 26116b5168b634..b73aa5550dd089 100644 --- a/Mathlib/Order/BooleanSubalgebra.lean +++ b/Mathlib/Order/BooleanSubalgebra.lean @@ -126,8 +126,8 @@ instance (L : BooleanSubalgebra α) : PartialOrder L := /-- A Boolean subalgebra of a lattice inherits a Boolean algebra structure. -/ instance instBooleanAlgebraCoe (L : BooleanSubalgebra α) : BooleanAlgebra L := - fast_instance% Subtype.coe_injective.booleanAlgebra _ .rfl .rfl val_sup val_inf val_top val_bot val_compl - val_sdiff val_himp + fast_instance% Subtype.coe_injective.booleanAlgebra _ .rfl .rfl val_sup val_inf val_top val_bot + val_compl val_sdiff val_himp /-- The natural lattice hom from a Boolean subalgebra to the original lattice. -/ def subtype (L : BooleanSubalgebra α) : BoundedLatticeHom L α where diff --git a/Mathlib/Order/OmegaCompletePartialOrder.lean b/Mathlib/Order/OmegaCompletePartialOrder.lean index b9a9326db0dd88..356b37e3f92676 100644 --- a/Mathlib/Order/OmegaCompletePartialOrder.lean +++ b/Mathlib/Order/OmegaCompletePartialOrder.lean @@ -475,7 +475,8 @@ protected def ωSup (c : Chain (α →o β)) : α →o β where @[simps! ωSup_coe] instance omegaCompletePartialOrder : OmegaCompletePartialOrder (α →o β) := - fast_instance% OmegaCompletePartialOrder.lift OrderHom.coeFnHom OrderHom.ωSup (fun _ _ h => h) fun _ => rfl + fast_instance% OmegaCompletePartialOrder.lift OrderHom.coeFnHom OrderHom.ωSup + (fun _ _ h => h) fun _ => rfl end OrderHom From cac073fb8b6d4756715cd1293a772636b0f13ba1 Mon Sep 17 00:00:00 2001 From: Kevin Buzzard Date: Sun, 24 May 2026 21:24:09 +0100 Subject: [PATCH 06/30] document sweep_fast_instance.py in scripts/README.md --- scripts/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/README.md b/scripts/README.md index 1757c86e82e9d1..6f29db8b8196ed 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -51,6 +51,11 @@ file used by the library's own linters. names used within namespaces (e.g., `lt_iff_val_lt_val`). Only processes files that exist in the current repository. Safe to run multiple times; processes all warnings in a single pass. Usage: `python3 scripts/fix_deprecations.py` +- `sweep_fast_instance.py` + Wraps `instance` bodies whose RHS uses a known smart constructor with `fast_instance%`, + then rebuilds the file and reverts the edit if it breaks the build or triggers the + `linter.fast_instance_existing` warning. Supports parallel sweeps over a subtree. + Usage: `python3 scripts/sweep_fast_instance.py [-j N] [--dry-run] ` - `add_deprecations.sh` is a text-based script that automatically adds deprecation statements. It assumes that the only difference between master and the current status of the PR consists of renames. More precisely, any change on a line that contains a declaration name From fc4c3e8498a32c9956e5e77d66626c9ea6850ba4 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 00:12:59 +0200 Subject: [PATCH 07/30] more files --- Mathlib/Algebra/Ring/Subsemiring/Basic.lean | 2 +- .../AlgebraicGeometry/IdealSheaf/Basic.lean | 2 +- .../ProjectiveSpectrum/Topology.lean | 2 +- .../SimplicialComplex/Basic.lean | 4 +- .../SimplicialSet/NonDegenerateSimplices.lean | 2 +- .../NonDegenerateSimplicesSubcomplex.lean | 2 +- .../SimplicialSet/Simplices.lean | 2 +- .../BoxIntegral/Partition/Additive.lean | 2 +- .../BoxIntegral/Partition/Filter.lean | 2 +- .../Analysis/CStarAlgebra/Module/Synonym.lean | 2 +- .../Complex/UpperHalfPlane/MoebiusAction.lean | 2 +- Mathlib/Analysis/Convex/Body.lean | 6 +-- .../Analysis/Normed/Algebra/Unitization.lean | 2 +- .../Normed/Algebra/UnitizationL1.lean | 2 +- Mathlib/Analysis/Normed/Field/UnitBall.lean | 6 +-- .../Analysis/Normed/Group/Constructions.lean | 8 +-- Mathlib/Analysis/Normed/Group/Hom.lean | 4 +- .../Analysis/Normed/Group/SemiNormedGrp.lean | 2 +- Mathlib/Analysis/Normed/Group/Seminorm.lean | 16 +++--- Mathlib/Analysis/Normed/Lp/PiLp.lean | 4 +- Mathlib/Analysis/Normed/Lp/ProdLp.lean | 4 +- Mathlib/Analysis/ODE/PicardLindelof.lean | 2 +- Mathlib/CategoryTheory/Abelian/Basic.lean | 4 +- .../Abelian/NonPreadditive.lean | 2 +- .../CategoryTheory/FinCategory/AsType.lean | 2 +- Mathlib/CategoryTheory/FinCategory/Basic.lean | 2 +- .../Limits/Indization/Category.lean | 2 +- Mathlib/CategoryTheory/Monoidal/CommGrp_.lean | 2 +- Mathlib/CategoryTheory/Monoidal/CommMon_.lean | 2 +- .../CategoryTheory/Monoidal/Limits/Basic.lean | 2 +- .../CategoryTheory/Monoidal/Subcategory.lean | 2 +- .../Monoidal/Widesubcategory.lean | 2 +- .../MorphismProperty/Limits.lean | 2 +- .../Enumerative/Composition.lean | 4 +- .../Combinatorics/Enumerative/DyckWord.lean | 2 +- .../Enumerative/IncidenceAlgebra.lean | 12 ++--- Mathlib/Combinatorics/SimpleGraph/Dart.lean | 2 +- Mathlib/Combinatorics/SimpleGraph/Finite.lean | 2 +- .../SimpleGraph/Finsubgraph.lean | 4 +- Mathlib/Combinatorics/SimpleGraph/Prod.lean | 2 +- .../Combinatorics/SimpleGraph/Subgraph.lean | 2 +- Mathlib/Combinatorics/Young/YoungDiagram.lean | 2 +- Mathlib/Computability/TuringMachine/Tape.lean | 5 +- Mathlib/Data/DFinsupp/Defs.lean | 14 ++--- Mathlib/Data/DFinsupp/FiniteInfinite.lean | 2 +- Mathlib/Data/DFinsupp/Module.lean | 2 +- Mathlib/Data/DList/Instances.lean | 2 +- Mathlib/Data/Finsupp/Basic.lean | 4 +- Mathlib/Data/Finsupp/Fintype.lean | 2 +- Mathlib/Data/Finsupp/Pointwise.lean | 18 +++---- Mathlib/Data/Fintype/Basic.lean | 8 +-- Mathlib/Data/Fintype/Pi.lean | 2 +- Mathlib/Data/Fintype/Sigma.lean | 2 +- Mathlib/Data/Fintype/Units.lean | 2 +- Mathlib/Data/Multiset/Fintype.lean | 2 +- Mathlib/Data/Sym/Basic.lean | 2 +- Mathlib/FieldTheory/Galois/GaloisClosure.lean | 2 +- Mathlib/Geometry/Diffeology/Basic.lean | 2 +- .../Manifold/Algebra/SmoothFunctions.lean | 8 +-- .../Geometry/Manifold/StructureGroupoid.lean | 2 +- Mathlib/GroupTheory/Congruence/Defs.lean | 2 +- Mathlib/GroupTheory/GroupAction/ConjAct.lean | 2 +- .../GroupAction/DomAct/ActionHom.lean | 4 +- .../GroupTheory/GroupAction/DomAct/Basic.lean | 8 +-- .../GroupTheory/GroupAction/Embedding.lean | 2 +- .../GroupTheory/GroupAction/OfQuotient.lean | 2 +- .../GroupTheory/GroupAction/SubMulAction.lean | 4 +- Mathlib/GroupTheory/Perm/Cycle/Type.lean | 2 +- .../GroupTheory/SpecificGroups/Dihedral.lean | 2 +- .../SpecificGroups/Quaternion.lean | 2 +- Mathlib/LinearAlgebra/AffineSpace/Basis.lean | 4 +- Mathlib/LinearAlgebra/Basis/SMul.lean | 2 +- .../Matrix/GeneralLinearGroup/Defs.lean | 2 +- .../Matrix/SpecialLinearGroup.lean | 4 +- .../LinearAlgebra/QuadraticForm/Basic.lean | 4 +- Mathlib/Logic/Embedding/Basic.lean | 3 +- Mathlib/Logic/Encodable/Basic.lean | 12 ++--- Mathlib/Logic/Encodable/Pi.lean | 6 +-- Mathlib/Logic/Equiv/Array.lean | 2 +- Mathlib/Logic/Equiv/Defs.lean | 5 +- Mathlib/Logic/Equiv/PartialEquiv.lean | 2 +- Mathlib/MeasureTheory/Function/AEEqFun.lean | 4 +- .../MeasureTheory/Function/SimpleFunc.lean | 4 +- .../MeasurableSpace/Constructions.lean | 2 +- .../MeasurableSpace/MeasurablyGenerated.lean | 2 +- .../MeasureTheory/Measure/FiniteMeasure.lean | 4 +- .../Measure/ProbabilityMeasure.lean | 2 +- .../MeasureTheory/VectorMeasure/Basic.lean | 8 +-- Mathlib/NumberTheory/ModularForms/Basic.lean | 12 ++--- .../ModularForms/SlashInvariantForms.lean | 2 +- .../NumberField/InfinitePlace/Embeddings.lean | 2 +- Mathlib/Order/BoundedOrder/Basic.lean | 3 +- Mathlib/Order/Filter/Germ/Basic.lean | 2 +- Mathlib/Order/Heyting/Hom.lean | 7 +-- Mathlib/Order/Heyting/Regular.lean | 4 +- Mathlib/Order/Hom/Basic.lean | 5 +- Mathlib/Order/Hom/Bounded.lean | 5 +- Mathlib/Order/Hom/BoundedLattice.lean | 3 +- Mathlib/Order/Hom/CompleteLattice.lean | 2 +- Mathlib/Order/Hom/Lattice.lean | 9 ++-- Mathlib/Order/UpperLower/CompleteLattice.lean | 8 +-- Mathlib/Probability/Kernel/Defs.lean | 2 +- .../RingTheory/AdicCompletion/Algebra.lean | 2 +- .../DedekindDomain/FiniteAdeleRing.lean | 2 +- Mathlib/RingTheory/Derivation/Basic.lean | 4 +- Mathlib/RingTheory/Extension/Basic.lean | 4 +- Mathlib/RingTheory/FractionalIdeal/Basic.lean | 4 +- Mathlib/RingTheory/HahnSeries/Lex.lean | 2 +- Mathlib/RingTheory/Ideal/Quotient/Defs.lean | 4 +- .../IntegralClosure/IntegralRestrict.lean | 2 +- .../LocalRing/ResidueField/Basic.lean | 2 +- .../RingTheory/Spectrum/Maximal/Topology.lean | 2 +- Mathlib/RingTheory/Spectrum/Prime/Defs.lean | 2 +- .../RingTheory/Valuation/ValuationRing.lean | 10 ++-- Mathlib/SetTheory/Cardinal/Defs.lean | 5 +- Mathlib/SetTheory/ZFC/PSet.lean | 2 +- Mathlib/Topology/Algebra/Constructions.lean | 2 +- .../Topology/Algebra/ContinuousAffineMap.lean | 6 +-- .../Algebra/Group/ClosedSubgroup.lean | 2 +- .../Topology/Algebra/Group/CompactOpen.lean | 2 +- .../Topology/Algebra/Group/GroupTopology.lean | 2 +- .../Module/ContinuousLinearMap/Basic.lean | 2 +- .../Algebra/Module/Spaces/WeakBilin.lean | 2 +- Mathlib/Topology/Algebra/OpenSubgroup.lean | 4 +- .../Algebra/RestrictedProduct/Basic.lean | 12 ++--- Mathlib/Topology/Algebra/Ring/Basic.lean | 2 +- Mathlib/Topology/Bornology/Constructions.lean | 2 +- Mathlib/Topology/Connected/PathConnected.lean | 2 +- .../ContinuousMap/Bounded/Normed.lean | 4 +- Mathlib/Topology/EMetricSpace/Defs.lean | 14 ++--- .../Topology/FiberBundle/Constructions.lean | 2 +- Mathlib/Topology/Homotopy/HomotopyGroup.lean | 2 +- Mathlib/Topology/Homotopy/Path.lean | 2 +- Mathlib/Topology/LocallyConstant/Algebra.lean | 54 +++++++++---------- Mathlib/Topology/MetricSpace/Basic.lean | 2 +- Mathlib/Topology/MetricSpace/Bilipschitz.lean | 2 +- .../MetricSpace/Pseudo/Constructions.lean | 4 +- Mathlib/Topology/Order/Hom/Basic.lean | 4 +- Mathlib/Topology/Sets/Order.lean | 4 +- Mathlib/Topology/Sheaves/CommRingCat.lean | 2 +- Mathlib/Topology/UniformSpace/Basic.lean | 2 +- 141 files changed, 290 insertions(+), 280 deletions(-) diff --git a/Mathlib/Algebra/Ring/Subsemiring/Basic.lean b/Mathlib/Algebra/Ring/Subsemiring/Basic.lean index 7e9b9150b35264..d3a7ab89c659ad 100644 --- a/Mathlib/Algebra/Ring/Subsemiring/Basic.lean +++ b/Mathlib/Algebra/Ring/Subsemiring/Basic.lean @@ -35,7 +35,7 @@ variable [SetLike S R] [hSR : SubsemiringClass S R] (s : S) namespace SubsemiringClass instance instCharZero [CharZero R] : CharZero s := - fast_instance% ⟨Function.Injective.of_comp (f := Subtype.val) (g := Nat.cast (R := s)) Nat.cast_injective⟩ + ⟨Function.Injective.of_comp (f := Subtype.val) (g := Nat.cast (R := s)) Nat.cast_injective⟩ end SubsemiringClass diff --git a/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean b/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean index 1fc0aa23ea3f12..49f646344f438f 100644 --- a/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean +++ b/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean @@ -85,7 +85,7 @@ protected lemma ext {I J : X.IdealSheafData} (h : I.ideal = J.ideal) : I = J := section Order -instance : PartialOrder (IdealSheafData X) := PartialOrder.lift ideal fun _ _ ↦ IdealSheafData.ext +instance : PartialOrder (IdealSheafData X) := fast_instance% PartialOrder.lift ideal fun _ _ ↦ IdealSheafData.ext lemma le_def {I J : IdealSheafData X} : I ≤ J ↔ ∀ U, I.ideal U ≤ J.ideal U := .rfl diff --git a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean index bdb664d7556e7f..fb6dae4663f657 100644 --- a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean +++ b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean @@ -413,7 +413,7 @@ where `x ≤ y` if and only if `y ∈ closure {x}`. instance : PartialOrder (ProjectiveSpectrum 𝒜) := - PartialOrder.lift asHomogeneousIdeal fun ⟨_, _, _⟩ ⟨_, _, _⟩ => by simp only [mk.injEq, imp_self] + fast_instance% PartialOrder.lift asHomogeneousIdeal fun ⟨_, _, _⟩ ⟨_, _, _⟩ => by simp only [mk.injEq, imp_self] @[simp] theorem as_ideal_le_as_ideal (x y : ProjectiveSpectrum 𝒜) : diff --git a/Mathlib/AlgebraicTopology/SimplicialComplex/Basic.lean b/Mathlib/AlgebraicTopology/SimplicialComplex/Basic.lean index f4e3319e7a0e03..08f08bb54bd480 100644 --- a/Mathlib/AlgebraicTopology/SimplicialComplex/Basic.lean +++ b/Mathlib/AlgebraicTopology/SimplicialComplex/Basic.lean @@ -81,7 +81,7 @@ instance : IsConcreteLE (PreAbstractSimplicialComplex ι) (Finset ι) where coe_subset_coe' := .rfl instance : PartialOrder (PreAbstractSimplicialComplex ι) := - PartialOrder.lift (fun K => K.faces) (fun _ _ => PreAbstractSimplicialComplex.ext) + fast_instance% PartialOrder.lift (fun K => K.faces) (fun _ _ => PreAbstractSimplicialComplex.ext) instance : SupSet (PreAbstractSimplicialComplex ι) where sSup s := @@ -205,7 +205,7 @@ instance : IsConcreteLE (AbstractSimplicialComplex ι) (Finset ι) where coe_subset_coe' := .rfl instance : PartialOrder (AbstractSimplicialComplex ι) := - PartialOrder.lift (fun K => K.faces) (fun _ _ => AbstractSimplicialComplex.ext) + fast_instance% PartialOrder.lift (fun K => K.faces) (fun _ _ => AbstractSimplicialComplex.ext) theorem toPreAbstractSimplicialComplex_injective : Function.Injective (toPreAbstractSimplicialComplex (ι := ι)) := diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/NonDegenerateSimplices.lean b/Mathlib/AlgebraicTopology/SimplicialSet/NonDegenerateSimplices.lean index 4c0a7b35ff51bc..7e7d327581bc63 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/NonDegenerateSimplices.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/NonDegenerateSimplices.lean @@ -71,7 +71,7 @@ lemma ext_iff (x y : X.N) : x = y ↔ x.toS = y.toS := by grind [cases SSet.N] -instance : Preorder X.N := Preorder.lift toS +instance : Preorder X.N := fast_instance% Preorder.lift toS lemma le_iff {x y : X.N} : x ≤ y ↔ x.subcomplex ≤ y.subcomplex := Iff.rfl diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/NonDegenerateSimplicesSubcomplex.lean b/Mathlib/AlgebraicTopology/SimplicialSet/NonDegenerateSimplicesSubcomplex.lean index c341c854657c51..4ae83b8f2e3cec 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/NonDegenerateSimplicesSubcomplex.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/NonDegenerateSimplicesSubcomplex.lean @@ -73,7 +73,7 @@ lemma eq_iff_sMk_eq {X : SSet.{u}} {A : X.Subcomplex} (x y : A.N) : rw [N.ext_iff, SSet.N.ext_iff] instance : PartialOrder A.N := - PartialOrder.lift toN (fun _ _ ↦ by simp [ext_iff]) + fast_instance% PartialOrder.lift toN (fun _ _ ↦ by simp [ext_iff]) lemma le_iff {x y : A.N} : x ≤ y ↔ x.toN ≤ y.toN := Iff.rfl diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/Simplices.lean b/Mathlib/AlgebraicTopology/SimplicialSet/Simplices.lean index 954be17519ec39..e49115932ce3c4 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/Simplices.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/Simplices.lean @@ -117,7 +117,7 @@ see `SSet.S.le_def` and `SSet.S.le_iff`. Note that the category structure on `X.S` induced by this preorder is not the "category of simplices" of `X` (which is see `X.Elementsᵒᵖ`); see `SSet.S.le_iff_nonempty_hom` for the precise relation. -/ -instance : Preorder X.S := Preorder.lift subcomplex +instance : Preorder X.S := fast_instance% Preorder.lift subcomplex lemma le_def {s t : X.S} : s ≤ t ↔ s.subcomplex ≤ t.subcomplex := Iff.rfl diff --git a/Mathlib/Analysis/BoxIntegral/Partition/Additive.lean b/Mathlib/Analysis/BoxIntegral/Partition/Additive.lean index 3365229aeb8a61..a43ed6bd785205 100644 --- a/Mathlib/Analysis/BoxIntegral/Partition/Additive.lean +++ b/Mathlib/Analysis/BoxIntegral/Partition/Additive.lean @@ -99,7 +99,7 @@ instance {R} [Monoid R] [DistribMulAction R M] : SMul R (ι →ᵇᵃ[I₀] M) : simp only [Pi.smul_apply, ← smul_sum, sum_partition_boxes _ hI hπ]⟩⟩ instance : AddCommMonoid (ι →ᵇᵃ[I₀] M) := - Function.Injective.addCommMonoid _ coe_injective rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Function.Injective.addCommMonoid _ coe_injective rfl (fun _ _ => rfl) fun _ _ => rfl @[simp] theorem map_split_add (f : ι →ᵇᵃ[I₀] M) (hI : ↑I ≤ I₀) (i : ι) (x : ℝ) : diff --git a/Mathlib/Analysis/BoxIntegral/Partition/Filter.lean b/Mathlib/Analysis/BoxIntegral/Partition/Filter.lean index f24f2a31d29d65..146e95c49ab19d 100644 --- a/Mathlib/Analysis/BoxIntegral/Partition/Filter.lean +++ b/Mathlib/Analysis/BoxIntegral/Partition/Filter.lean @@ -207,7 +207,7 @@ def equivProd : IntegrationParams ≃ Bool × Boolᵒᵈ × Boolᵒᵈ where invFun l := ⟨l.1, OrderDual.ofDual l.2.1, OrderDual.ofDual l.2.2⟩ instance : PartialOrder IntegrationParams := - PartialOrder.lift equivProd equivProd.injective + fast_instance% PartialOrder.lift equivProd equivProd.injective /-- Auxiliary `OrderIso` with a product type used to lift a `BoundedOrder` structure. -/ def isoProd : IntegrationParams ≃o Bool × Boolᵒᵈ × Boolᵒᵈ := diff --git a/Mathlib/Analysis/CStarAlgebra/Module/Synonym.lean b/Mathlib/Analysis/CStarAlgebra/Module/Synonym.lean index dd10e630df16d7..d1ea72463fdb8d 100644 --- a/Mathlib/Analysis/CStarAlgebra/Module/Synonym.lean +++ b/Mathlib/Analysis/CStarAlgebra/Module/Synonym.lean @@ -186,7 +186,7 @@ variable {A E} instance [u : UniformSpace E] : UniformSpace C⋆ᵐᵒᵈ(A, E) := u.comap <| equiv A E -instance [Bornology E] : Bornology C⋆ᵐᵒᵈ(A, E) := Bornology.induced <| equiv A E +instance [Bornology E] : Bornology C⋆ᵐᵒᵈ(A, E) := fast_instance% Bornology.induced <| equiv A E /-- `WithCStarModule.equiv` as a uniform equivalence between `C⋆ᵐᵒᵈ(A, E)` and `E`. -/ diff --git a/Mathlib/Analysis/Complex/UpperHalfPlane/MoebiusAction.lean b/Mathlib/Analysis/Complex/UpperHalfPlane/MoebiusAction.lean index 428cfdac9f9da6..ffdefaf57f4d29 100644 --- a/Mathlib/Analysis/Complex/UpperHalfPlane/MoebiusAction.lean +++ b/Mathlib/Analysis/Complex/UpperHalfPlane/MoebiusAction.lean @@ -287,7 +287,7 @@ end PGLAction section SLAction noncomputable instance SLAction {R : Type*} [CommRing R] [Algebra R ℝ] : MulAction SL(2, R) ℍ := - MulAction.compHom ℍ <| SpecialLinearGroup.mapGL ℝ + fast_instance% MulAction.compHom ℍ <| SpecialLinearGroup.mapGL ℝ theorem coe_specialLinearGroup_apply {R : Type*} [CommRing R] [Algebra R ℝ] (g : SL(2, R)) (z : ℍ) : ↑(g • z) = diff --git a/Mathlib/Analysis/Convex/Body.lean b/Mathlib/Analysis/Convex/Body.lean index d57ec34516190e..98cf6a0f48fdad 100644 --- a/Mathlib/Analysis/Convex/Body.lean +++ b/Mathlib/Analysis/Convex/Body.lean @@ -121,14 +121,14 @@ theorem coe_nsmul : ∀ (n : ℕ) (K : ConvexBody V), ↑(n • K) = n • (K : | (n + 1), K => congr_arg₂ (Set.image2 (· + ·)) (coe_nsmul n K) rfl noncomputable instance : AddMonoid (ConvexBody V) := - SetLike.coe_injective.addMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ coe_nsmul _ _ + fast_instance% SetLike.coe_injective.addMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ coe_nsmul _ _ @[simp, norm_cast] theorem coe_add (K L : ConvexBody V) : (↑(K + L) : Set V) = (K : Set V) + L := rfl noncomputable instance : AddCommMonoid (ConvexBody V) := - SetLike.coe_injective.addCommMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ coe_nsmul _ _ + fast_instance% SetLike.coe_injective.addCommMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ coe_nsmul _ _ end ContinuousAdd @@ -160,7 +160,7 @@ theorem smul_le_of_le (K : ConvexBody V) (h_zero : 0 ∈ K) {a b : ℝ≥0} (h : variable [ContinuousAdd V] noncomputable instance : DistribMulAction ℝ (ConvexBody V) := - SetLike.coe_injective.distribMulAction ⟨⟨_, coe_zero⟩, coe_add⟩ coe_smul + fast_instance% SetLike.coe_injective.distribMulAction ⟨⟨_, coe_zero⟩, coe_add⟩ coe_smul /-- The convex bodies in a fixed space $V$ form a module over the nonnegative reals. -/ noncomputable instance : Module ℝ≥0 (ConvexBody V) where diff --git a/Mathlib/Analysis/Normed/Algebra/Unitization.lean b/Mathlib/Analysis/Normed/Algebra/Unitization.lean index f16916de4bc038..ac2e86090689db 100644 --- a/Mathlib/Analysis/Normed/Algebra/Unitization.lean +++ b/Mathlib/Analysis/Normed/Algebra/Unitization.lean @@ -209,7 +209,7 @@ def uniformEquivProd : (Unitization 𝕜 A) ≃ᵤ (𝕜 × A) := /-- The bornology on `Unitization 𝕜 A` is inherited from `𝕜 × A`. -/ instance instBornology : Bornology (Unitization 𝕜 A) := - Bornology.induced <| addEquiv 𝕜 A + fast_instance% Bornology.induced <| addEquiv 𝕜 A theorem isUniformEmbedding_addEquiv {𝕜} [NontriviallyNormedField 𝕜] : IsUniformEmbedding (addEquiv 𝕜 A) where diff --git a/Mathlib/Analysis/Normed/Algebra/UnitizationL1.lean b/Mathlib/Analysis/Normed/Algebra/UnitizationL1.lean index 3bc2a9e12ec42c..96ffe1ce5bdb00 100644 --- a/Mathlib/Analysis/Normed/Algebra/UnitizationL1.lean +++ b/Mathlib/Analysis/Normed/Algebra/UnitizationL1.lean @@ -43,7 +43,7 @@ noncomputable def unitization_addEquiv_prod : WithLp 1 (Unitization 𝕜 A) ≃+ noncomputable instance instUnitizationNormedAddCommGroup : NormedAddCommGroup (WithLp 1 (Unitization 𝕜 A)) := - NormedAddCommGroup.induced (WithLp 1 (Unitization 𝕜 A)) (WithLp 1 (𝕜 × A)) + fast_instance% NormedAddCommGroup.induced (WithLp 1 (Unitization 𝕜 A)) (WithLp 1 (𝕜 × A)) (unitization_addEquiv_prod 𝕜 A) (AddEquiv.injective _) /-- Bundle `WithLp.unitization_addEquiv_prod` as a `UniformEquiv`. -/ diff --git a/Mathlib/Analysis/Normed/Field/UnitBall.lean b/Mathlib/Analysis/Normed/Field/UnitBall.lean index 99252ea7420fb0..6fcfb8adaf6afe 100644 --- a/Mathlib/Analysis/Normed/Field/UnitBall.lean +++ b/Mathlib/Analysis/Normed/Field/UnitBall.lean @@ -52,7 +52,7 @@ instance Metric.unitBall.instCommSemigroup [SeminormedCommRing 𝕜] : instance Metric.unitBall.instHasDistribNeg [NonUnitalSeminormedRing 𝕜] : HasDistribNeg (ball (0 : 𝕜) 1) := - Subtype.coe_injective.hasDistribNeg ((↑) : ball (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl + fast_instance% Subtype.coe_injective.hasDistribNeg ((↑) : ball (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl @[simp, norm_cast] protected theorem Metric.unitBall.coe_mul [NonUnitalSeminormedRing 𝕜] (x y : ball (0 : 𝕜) 1) : @@ -105,7 +105,7 @@ instance Metric.unitClosedBall.instSemigroup [NonUnitalSeminormedRing 𝕜] : instance Metric.unitClosedBall.instHasDistribNeg [NonUnitalSeminormedRing 𝕜] : HasDistribNeg (closedBall (0 : 𝕜) 1) := - Subtype.coe_injective.hasDistribNeg ((↑) : closedBall (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl + fast_instance% Subtype.coe_injective.hasDistribNeg ((↑) : closedBall (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl instance Metric.unitClosedBall.instContinuousMul [NonUnitalSeminormedRing 𝕜] : ContinuousMul (closedBall (0 : 𝕜) 1) := @@ -259,7 +259,7 @@ instance Metric.unitSphere.instGroup [NormedDivisionRing 𝕜] : Group (sphere ( instance Metric.sphere.instHasDistribNeg [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] : HasDistribNeg (sphere (0 : 𝕜) 1) := - Subtype.coe_injective.hasDistribNeg ((↑) : sphere (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl + fast_instance% Subtype.coe_injective.hasDistribNeg ((↑) : sphere (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl instance Metric.sphere.instContinuousMul [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] : ContinuousMul (sphere (0 : 𝕜) 1) := diff --git a/Mathlib/Analysis/Normed/Group/Constructions.lean b/Mathlib/Analysis/Normed/Group/Constructions.lean index 8d4161330a86ab..e1edcca5a5e0a4 100644 --- a/Mathlib/Analysis/Normed/Group/Constructions.lean +++ b/Mathlib/Analysis/Normed/Group/Constructions.lean @@ -65,21 +65,21 @@ end NNNorm @[to_additive] instance seminormedGroup [SeminormedGroup E] : SeminormedGroup (ULift E) := - SeminormedGroup.induced _ _ + fast_instance% SeminormedGroup.induced _ _ { toFun := ULift.down, map_one' := rfl, map_mul' := fun _ _ => rfl : ULift E →* E } @[to_additive] instance seminormedCommGroup [SeminormedCommGroup E] : SeminormedCommGroup (ULift E) := - SeminormedCommGroup.induced _ _ + fast_instance% SeminormedCommGroup.induced _ _ { toFun := ULift.down, map_one' := rfl, map_mul' := fun _ _ => rfl : ULift E →* E } @[to_additive] instance normedGroup [NormedGroup E] : NormedGroup (ULift E) := - NormedGroup.induced _ _ + fast_instance% NormedGroup.induced _ _ { toFun := ULift.down, map_one' := rfl, map_mul' := fun _ _ => rfl : ULift E →* E } @@ -87,7 +87,7 @@ instance normedGroup [NormedGroup E] : NormedGroup (ULift E) := @[to_additive] instance normedCommGroup [NormedCommGroup E] : NormedCommGroup (ULift E) := - NormedCommGroup.induced _ _ + fast_instance% NormedCommGroup.induced _ _ { toFun := ULift.down, map_one' := rfl, map_mul' := fun _ _ => rfl : ULift E →* E } diff --git a/Mathlib/Analysis/Normed/Group/Hom.lean b/Mathlib/Analysis/Normed/Group/Hom.lean index 06879c342507b4..1c56f47f8f885a 100644 --- a/Mathlib/Analysis/Normed/Group/Hom.lean +++ b/Mathlib/Analysis/Normed/Group/Hom.lean @@ -541,11 +541,11 @@ theorem sum_apply {ι : Type*} (s : Finset ι) (f : ι → NormedAddGroupHom V instance distribMulAction {R : Type*} [MonoidWithZero R] [DistribMulAction R V₂] [PseudoMetricSpace R] [IsBoundedSMul R V₂] : DistribMulAction R (NormedAddGroupHom V₁ V₂) := - Function.Injective.distribMulAction coeAddHom coe_injective coe_smul + fast_instance% Function.Injective.distribMulAction coeAddHom coe_injective coe_smul instance module {R : Type*} [Semiring R] [Module R V₂] [PseudoMetricSpace R] [IsBoundedSMul R V₂] : Module R (NormedAddGroupHom V₁ V₂) := - Function.Injective.module _ coeAddHom coe_injective coe_smul + fast_instance% Function.Injective.module _ coeAddHom coe_injective coe_smul /-! ### Composition of normed group homs -/ diff --git a/Mathlib/Analysis/Normed/Group/SemiNormedGrp.lean b/Mathlib/Analysis/Normed/Group/SemiNormedGrp.lean index 9340a9f55f8c3a..f6cf22f6659333 100644 --- a/Mathlib/Analysis/Normed/Group/SemiNormedGrp.lean +++ b/Mathlib/Analysis/Normed/Group/SemiNormedGrp.lean @@ -202,7 +202,7 @@ theorem hom_zsum {V W : SemiNormedGrp} (n : ℤ) (f : V ⟶ W) : (n • f).hom = rfl instance Hom.addCommGroup {V W : SemiNormedGrp} : AddCommGroup (V ⟶ W) := - Function.Injective.addCommGroup _ ConcreteCategory.hom_injective rfl (fun _ _ => rfl) + fast_instance% Function.Injective.addCommGroup _ ConcreteCategory.hom_injective rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) end SemiNormedGrp diff --git a/Mathlib/Analysis/Normed/Group/Seminorm.lean b/Mathlib/Analysis/Normed/Group/Seminorm.lean index f7df594f556219..2c6f093f828087 100644 --- a/Mathlib/Analysis/Normed/Group/Seminorm.lean +++ b/Mathlib/Analysis/Normed/Group/Seminorm.lean @@ -197,7 +197,7 @@ theorem ext : (∀ x, p x = q x) → p = q := @[to_additive] instance : PartialOrder (GroupSeminorm E) := - PartialOrder.lift _ DFunLike.coe_injective + fast_instance% PartialOrder.lift _ DFunLike.coe_injective @[to_additive] theorem le_def : p ≤ q ↔ (p : E → ℝ) ≤ q := @@ -319,7 +319,7 @@ theorem sup_apply (x : E) : (p ⊔ q) x = p x ⊔ q x := @[to_additive] instance semilatticeSup : SemilatticeSup (GroupSeminorm E) := - DFunLike.coe_injective.semilatticeSup _ .rfl .rfl coe_sup + fast_instance% DFunLike.coe_injective.semilatticeSup _ .rfl .rfl coe_sup /-- Composition of a group seminorm with a monoid homomorphism as a group seminorm. -/ @[to_additive /-- Composition of an additive group seminorm with an additive monoid homomorphism as @@ -495,7 +495,7 @@ theorem ext : (∀ x, p x = q x) → p = q := DFunLike.ext p q noncomputable instance : PartialOrder (NonarchAddGroupSeminorm E) := - PartialOrder.lift _ DFunLike.coe_injective + fast_instance% PartialOrder.lift _ DFunLike.coe_injective theorem le_def : p ≤ q ↔ (p : E → ℝ) ≤ q := Iff.rfl @@ -587,7 +587,7 @@ theorem sup_apply (x : E) : (p ⊔ q) x = p x ⊔ q x := rfl noncomputable instance : SemilatticeSup (NonarchAddGroupSeminorm E) := - DFunLike.coe_injective.semilatticeSup _ .rfl .rfl coe_sup + fast_instance% DFunLike.coe_injective.semilatticeSup _ .rfl .rfl coe_sup end AddGroup @@ -742,7 +742,7 @@ theorem ext : (∀ x, p x = q x) → p = q := @[to_additive] instance : PartialOrder (GroupNorm E) := - PartialOrder.lift _ DFunLike.coe_injective + fast_instance% PartialOrder.lift _ DFunLike.coe_injective @[to_additive] theorem le_def : p ≤ q ↔ (p : E → ℝ) ≤ q := @@ -797,7 +797,7 @@ theorem sup_apply (x : E) : (p ⊔ q) x = p x ⊔ q x := @[to_additive] instance : SemilatticeSup (GroupNorm E) := - DFunLike.coe_injective.semilatticeSup _ .rfl .rfl coe_sup + fast_instance% DFunLike.coe_injective.semilatticeSup _ .rfl .rfl coe_sup end Group @@ -866,7 +866,7 @@ theorem ext : (∀ x, p x = q x) → p = q := DFunLike.ext p q noncomputable instance : PartialOrder (NonarchAddGroupNorm E) := - PartialOrder.lift _ DFunLike.coe_injective + fast_instance% PartialOrder.lift _ DFunLike.coe_injective theorem le_def : p ≤ q ↔ (p : E → ℝ) ≤ q := Iff.rfl @@ -899,7 +899,7 @@ theorem sup_apply (x : E) : (p ⊔ q) x = p x ⊔ q x := rfl noncomputable instance : SemilatticeSup (NonarchAddGroupNorm E) := - DFunLike.coe_injective.semilatticeSup _ .rfl .rfl coe_sup + fast_instance% DFunLike.coe_injective.semilatticeSup _ .rfl .rfl coe_sup instance [DecidableEq E] : One (NonarchAddGroupNorm E) := ⟨{ (1 : NonarchAddGroupSeminorm E) with diff --git a/Mathlib/Analysis/Normed/Lp/PiLp.lean b/Mathlib/Analysis/Normed/Lp/PiLp.lean index 99a53333c347a5..8460d686d2656c 100644 --- a/Mathlib/Analysis/Normed/Lp/PiLp.lean +++ b/Mathlib/Analysis/Normed/Lp/PiLp.lean @@ -517,7 +517,7 @@ private lemma uniformity_aux : 𝓤 (PiLp p β) = 𝓤[UniformSpace.comap ofLp i rfl instance bornology (p : ℝ≥0∞) (β : ι → Type*) [∀ i, Bornology (β i)] : - Bornology (PiLp p β) := Bornology.induced ofLp + Bornology (PiLp p β) := fast_instance% Bornology.induced ofLp set_option backward.privateInPublic true in private lemma cobounded_aux : @cobounded _ PseudoMetricSpace.toBornology = cobounded (PiLp p α) := @@ -529,7 +529,7 @@ end Aux /-! ### Instances on finite `L^p` products -/ instance topologicalSpace [∀ i, TopologicalSpace (β i)] : TopologicalSpace (PiLp p β) := - Pi.topologicalSpace.induced ofLp + fast_instance% Pi.topologicalSpace.induced ofLp @[fun_prop, continuity] theorem continuous_ofLp [∀ i, TopologicalSpace (β i)] : Continuous (@ofLp p (∀ i, β i)) := diff --git a/Mathlib/Analysis/Normed/Lp/ProdLp.lean b/Mathlib/Analysis/Normed/Lp/ProdLp.lean index 42446607269ab1..4a8ba38dd32937 100644 --- a/Mathlib/Analysis/Normed/Lp/ProdLp.lean +++ b/Mathlib/Analysis/Normed/Lp/ProdLp.lean @@ -457,7 +457,7 @@ private lemma prod_uniformity_aux [PseudoEMetricSpace α] [PseudoEMetricSpace β rfl instance instProdBornology (p : ℝ≥0∞) (α β : Type*) [Bornology α] [Bornology β] : - Bornology (WithLp p (α × β)) := Bornology.induced ofLp + Bornology (WithLp p (α × β)) := fast_instance% Bornology.induced ofLp set_option backward.privateInPublic true in private lemma prod_cobounded_aux [PseudoMetricSpace α] [PseudoMetricSpace β] : @@ -474,7 +474,7 @@ section TopologicalSpace variable [TopologicalSpace α] [TopologicalSpace β] instance instProdTopologicalSpace : TopologicalSpace (WithLp p (α × β)) := - instTopologicalSpaceProd.induced ofLp + fast_instance% instTopologicalSpaceProd.induced ofLp @[continuity, fun_prop] lemma prod_continuous_toLp : Continuous (@toLp p (α × β)) := diff --git a/Mathlib/Analysis/ODE/PicardLindelof.lean b/Mathlib/Analysis/ODE/PicardLindelof.lean index edfe54041d89bb..23c91027f0aab5 100644 --- a/Mathlib/Analysis/ODE/PicardLindelof.lean +++ b/Mathlib/Analysis/ODE/PicardLindelof.lean @@ -187,7 +187,7 @@ lemma apply_of_zero (α : FunSpace t₀ x₀ 0 L) : α t₀ = x₀ := by over all `t` in the domain. This is finite when the domain is compact, such as a closed interval in our case. -/ noncomputable instance : MetricSpace (FunSpace t₀ x₀ r L) := - MetricSpace.induced toContinuousMap toContinuousMap.injective inferInstance + fast_instance% MetricSpace.induced toContinuousMap toContinuousMap.injective inferInstance lemma isUniformInducing_toContinuousMap : IsUniformInducing fun α : FunSpace t₀ x₀ r L ↦ α.toContinuousMap := ⟨rfl⟩ diff --git a/Mathlib/CategoryTheory/Abelian/Basic.lean b/Mathlib/CategoryTheory/Abelian/Basic.lean index 3a5b9159bebe86..9f7d3225a75779 100644 --- a/Mathlib/CategoryTheory/Abelian/Basic.lean +++ b/Mathlib/CategoryTheory/Abelian/Basic.lean @@ -738,7 +738,7 @@ variable [Limits.HasPushouts C] {W X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) set_option backward.isDefEq.respectTransparency false in instance mono_pushout_of_mono_f [Mono f] : Mono (pushout.inr _ _ : Z ⟶ pushout f g) := - fast_instance% mono_of_cancel_zero _ fun {R} e h => by + mono_of_cancel_zero _ fun {R} e h => by let u := biprod.lift (0 : R ⟶ Y) e have hu : u ≫ BiproductToPushoutIsCokernel.biproductToPushout f g = 0 := by simpa [u] have := @@ -761,7 +761,7 @@ instance mono_pushout_of_mono_f [Mono f] : Mono (pushout.inr _ _ : Z ⟶ pushout set_option backward.isDefEq.respectTransparency false in instance mono_pushout_of_mono_g [Mono g] : Mono (pushout.inl f g) := - fast_instance% mono_of_cancel_zero _ fun {R} e h => by + mono_of_cancel_zero _ fun {R} e h => by let u := biprod.lift e (0 : R ⟶ Z) have hu : u ≫ BiproductToPushoutIsCokernel.biproductToPushout f g = 0 := by simpa [u] have := diff --git a/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean b/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean index 03da7309e92556..21e1139fae40f8 100644 --- a/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean +++ b/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean @@ -146,7 +146,7 @@ instance isIso_factorThruImage [Mono f] : IsIso (Abelian.factorThruImage f) := /-- The canonical morphism `i : coimage f ⟶ Q` is a monomorphism -/ instance : Mono (Abelian.factorThruCoimage f) := - fast_instance% let I := Abelian.coimage f + let I := Abelian.coimage f let i := Abelian.factorThruCoimage f let p := cokernel.π (kernel.ι f) NormalEpiCategory.mono_of_cancel_zero _ fun R (g : R ⟶ I) (hgi : g ≫ i = 0) => by diff --git a/Mathlib/CategoryTheory/FinCategory/AsType.lean b/Mathlib/CategoryTheory/FinCategory/AsType.lean index 4cd3c126172ccb..fac5898ee0c693 100644 --- a/Mathlib/CategoryTheory/FinCategory/AsType.lean +++ b/Mathlib/CategoryTheory/FinCategory/AsType.lean @@ -31,7 +31,7 @@ abbrev ObjAsType : Type := InducedCategory α (Fintype.equivFin α).symm instance {i j : ObjAsType α} : Fintype (i ⟶ j) := - Fintype.ofEquiv _ InducedCategory.homEquiv.symm + fast_instance% Fintype.ofEquiv _ InducedCategory.homEquiv.symm /-- The constructed category is indeed equivalent to `α`. -/ noncomputable def objAsTypeEquiv : ObjAsType α ≌ α := diff --git a/Mathlib/CategoryTheory/FinCategory/Basic.lean b/Mathlib/CategoryTheory/FinCategory/Basic.lean index 513718478837fd..9191b00e451269 100644 --- a/Mathlib/CategoryTheory/FinCategory/Basic.lean +++ b/Mathlib/CategoryTheory/FinCategory/Basic.lean @@ -32,7 +32,7 @@ noncomputable section namespace CategoryTheory instance discreteFintype {α : Type*} [Fintype α] : Fintype (Discrete α) := - Fintype.ofEquiv α discreteEquiv.symm + fast_instance% Fintype.ofEquiv α discreteEquiv.symm instance {α : Type*} [Finite α] : Finite (Discrete α) := Finite.of_equiv α discreteEquiv.symm diff --git a/Mathlib/CategoryTheory/Limits/Indization/Category.lean b/Mathlib/CategoryTheory/Limits/Indization/Category.lean index a705f560e5ae7a..9d9ef591d49f88 100644 --- a/Mathlib/CategoryTheory/Limits/Indization/Category.lean +++ b/Mathlib/CategoryTheory/Limits/Indization/Category.lean @@ -158,7 +158,7 @@ instance [HasLimitsOfShape WalkingParallelPair C] : hasLimitsOfShape_of_hasLimitsOfShape_createsLimitsOfShape (Ind.inclusion C) noncomputable instance [HasFiniteLimits C] : CreatesFiniteLimits (Ind.inclusion C) := - letI _ : CreatesFiniteProducts (Ind.inclusion C) := + fast_instance% letI _ : CreatesFiniteProducts (Ind.inclusion C) := { creates _ _ := createsLimitsOfShapeOfEquiv (Discrete.equivalence Equiv.ulift) _ } createsFiniteLimitsOfCreatesEqualizersAndFiniteProducts (Ind.inclusion C) diff --git a/Mathlib/CategoryTheory/Monoidal/CommGrp_.lean b/Mathlib/CategoryTheory/Monoidal/CommGrp_.lean index ea4d695bfe39ee..53e859bd61d608 100644 --- a/Mathlib/CategoryTheory/Monoidal/CommGrp_.lean +++ b/Mathlib/CategoryTheory/Monoidal/CommGrp_.lean @@ -179,7 +179,7 @@ set_option backward.privateInPublic true in end instance uniqueHomFromTrivial (A : CommGrp C) : Unique (trivial C ⟶ A) := - Equiv.unique (show _ ≃ (Grp.trivial C ⟶ A.toGrp) from + fast_instance% Equiv.unique (show _ ≃ (Grp.trivial C ⟶ A.toGrp) from InducedCategory.homEquiv) instance : HasInitial (CommGrp C) := diff --git a/Mathlib/CategoryTheory/Monoidal/CommMon_.lean b/Mathlib/CategoryTheory/Monoidal/CommMon_.lean index 2dd6a6d06f0224..6e01956c617b32 100644 --- a/Mathlib/CategoryTheory/Monoidal/CommMon_.lean +++ b/Mathlib/CategoryTheory/Monoidal/CommMon_.lean @@ -134,7 +134,7 @@ abbrev mkIso {M N : CommMon C} (e : M.X ≅ N.X) (one_f : η[M.X] ≫ e.hom = η mkIso' e instance uniqueHomFromTrivial (A : CommMon C) : Unique (trivial C ⟶ A) := - Equiv.unique (show _ ≃ (Mon.trivial C ⟶ A.toMon) from + fast_instance% Equiv.unique (show _ ≃ (Mon.trivial C ⟶ A.toMon) from InducedCategory.homEquiv) open CategoryTheory.Limits diff --git a/Mathlib/CategoryTheory/Monoidal/Limits/Basic.lean b/Mathlib/CategoryTheory/Monoidal/Limits/Basic.lean index 4984e6b96136ed..38dab79d8a5a02 100644 --- a/Mathlib/CategoryTheory/Monoidal/Limits/Basic.lean +++ b/Mathlib/CategoryTheory/Monoidal/Limits/Basic.lean @@ -39,7 +39,7 @@ open Functor.LaxMonoidal set_option backward.isDefEq.respectTransparency false in instance : (lim (J := J) (C := C)).LaxMonoidal := - Functor.LaxMonoidal.ofTensorHom + fast_instance% Functor.LaxMonoidal.ofTensorHom (ε := limit.lift _ { pt := _ diff --git a/Mathlib/CategoryTheory/Monoidal/Subcategory.lean b/Mathlib/CategoryTheory/Monoidal/Subcategory.lean index 4995579c13a735..5b81c0308c15ea 100644 --- a/Mathlib/CategoryTheory/Monoidal/Subcategory.lean +++ b/Mathlib/CategoryTheory/Monoidal/Subcategory.lean @@ -91,7 +91,7 @@ When `P : ObjectProperty C` is monoidal, the full subcategory for `P` inherits t monoidal structure of `C`. -/ instance fullMonoidalSubcategory : MonoidalCategory (FullSubcategory P) := - Monoidal.induced P.ι + fast_instance% Monoidal.induced P.ι { μIso _ _ := Iso.refl _ εIso := Iso.refl _ } diff --git a/Mathlib/CategoryTheory/Monoidal/Widesubcategory.lean b/Mathlib/CategoryTheory/Monoidal/Widesubcategory.lean index bce78634da2cc2..756f38a3beccda 100644 --- a/Mathlib/CategoryTheory/Monoidal/Widesubcategory.lean +++ b/Mathlib/CategoryTheory/Monoidal/Widesubcategory.lean @@ -81,7 +81,7 @@ instance [P.IsMonoidalStable] : MonoidalCategoryStruct (WideSubcategory P) where tensorHom f g := ⟨f.1 ⊗ₘ g.1, P.tensorHom_mem _ _ f.2 g.2⟩ instance [P.IsMonoidalStable] : MonoidalCategory (WideSubcategory P) := - Monoidal.induced (wideSubcategoryInclusion P) + fast_instance% Monoidal.induced (wideSubcategoryInclusion P) { εIso := Iso.refl _ μIso _ _ := Iso.refl _ } diff --git a/Mathlib/CategoryTheory/MorphismProperty/Limits.lean b/Mathlib/CategoryTheory/MorphismProperty/Limits.lean index 671a7835398f3b..9f5b8452764f34 100644 --- a/Mathlib/CategoryTheory/MorphismProperty/Limits.lean +++ b/Mathlib/CategoryTheory/MorphismProperty/Limits.lean @@ -446,7 +446,7 @@ lemma limitsOfShape_monotone {W₁ W₂ : MorphismProperty C} (h : W₁ ≤ W₂ set_option backward.isDefEq.respectTransparency false in instance : (W.limitsOfShape J).RespectsIso := - fast_instance% RespectsIso.of_respects_arrow_iso _ (by + RespectsIso.of_respects_arrow_iso _ (by rintro ⟨_, _, f⟩ ⟨Y₁, Y₂, g⟩ e ⟨X₁, X₂, c₁, c₂, h₁, h₂, f, hf⟩ let e₁ := Arrow.leftFunc.mapIso e let e₂ := Arrow.rightFunc.mapIso e diff --git a/Mathlib/Combinatorics/Enumerative/Composition.lean b/Mathlib/Combinatorics/Enumerative/Composition.lean index bf413e6446f813..567494b2c858a9 100644 --- a/Mathlib/Combinatorics/Enumerative/Composition.lean +++ b/Mathlib/Combinatorics/Enumerative/Composition.lean @@ -843,7 +843,7 @@ def compositionAsSetEquiv (n : ℕ) : CompositionAsSet n ≃ Finset (Fin (n - 1) exists_eq_right'] instance compositionAsSetFintype (n : ℕ) : Fintype (CompositionAsSet n) := - Fintype.ofEquiv _ (compositionAsSetEquiv n).symm + fast_instance% Fintype.ofEquiv _ (compositionAsSetEquiv n).symm theorem compositionAsSet_card (n : ℕ) : Fintype.card (CompositionAsSet n) = 2 ^ (n - 1) := by have : Fintype.card (Finset (Fin (n - 1))) = 2 ^ (n - 1) := by simp @@ -1019,7 +1019,7 @@ def compositionEquiv (n : ℕ) : Composition n ≃ CompositionAsSet n where exact c.toComposition_boundaries instance compositionFintype (n : ℕ) : Fintype (Composition n) := - Fintype.ofEquiv _ (compositionEquiv n).symm + fast_instance% Fintype.ofEquiv _ (compositionEquiv n).symm theorem composition_card (n : ℕ) : Fintype.card (Composition n) = 2 ^ (n - 1) := by rw [← compositionAsSet_card n] diff --git a/Mathlib/Combinatorics/Enumerative/DyckWord.lean b/Mathlib/Combinatorics/Enumerative/DyckWord.lean index bfe4d869675eef..dc411777d0eb55 100644 --- a/Mathlib/Combinatorics/Enumerative/DyckWord.lean +++ b/Mathlib/Combinatorics/Enumerative/DyckWord.lean @@ -539,7 +539,7 @@ def equivTreesOfNumNodesEq (n : ℕ) : { p : DyckWord // p.semilength = n } ≃ equivTree.subtypeEquiv (by simp) instance {n : ℕ} : Fintype { p : DyckWord // p.semilength = n } := - Fintype.ofEquiv _ (equivTreesOfNumNodesEq n).symm + fast_instance% Fintype.ofEquiv _ (equivTreesOfNumNodesEq n).symm /-- There are `catalan n` Dyck words of semilength `n` (or length `2 * n`). -/ theorem card_dyckWord_semilength_eq_catalan (n : ℕ) : diff --git a/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean b/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean index 453228069c5c0a..c29f1e3224cff4 100644 --- a/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean +++ b/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean @@ -156,10 +156,10 @@ lemma constSMul_apply (c : M) (f : IncidenceAlgebra 𝕜 α) (a b : α) : (c • end Smul instance instAddMonoid [AddMonoid 𝕜] [LE α] : AddMonoid (IncidenceAlgebra 𝕜 α) := - DFunLike.coe_injective.addMonoid _ coe_zero coe_add fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.addMonoid _ coe_zero coe_add fun _ _ ↦ rfl instance instAddCommMonoid [AddCommMonoid 𝕜] [LE α] : AddCommMonoid (IncidenceAlgebra 𝕜 α) := - DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add fun _ _ ↦ rfl section AddGroup variable [AddGroup 𝕜] [LE α] @@ -176,12 +176,12 @@ lemma neg_apply (f : IncidenceAlgebra 𝕜 α) (a b : α) : (-f) a b = -f a b := lemma sub_apply (f g : IncidenceAlgebra 𝕜 α) (a b : α) : (f - g) a b = f a b - g a b := rfl instance instAddGroup : AddGroup (IncidenceAlgebra 𝕜 α) := - DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ ↦ rfl) fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ ↦ rfl) fun _ _ ↦ rfl end AddGroup instance instAddCommGroup [AddCommGroup 𝕜] [LE α] : AddCommGroup (IncidenceAlgebra 𝕜 α) := - DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ ↦ rfl) + fast_instance% DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ ↦ rfl) fun _ _ ↦ rfl section One @@ -278,12 +278,12 @@ instance [Preorder α] [LocallyFiniteOrder α] [DecidableEq α] [Semiring 𝕜] instance smulWithZeroRight [Zero 𝕜] [Zero 𝕝] [SMulWithZero 𝕜 𝕝] [LE α] : SMulWithZero 𝕜 (IncidenceAlgebra 𝕝 α) := - DFunLike.coe_injective.smulWithZero ⟨((⇑) : IncidenceAlgebra 𝕝 α → α → α → 𝕝), coe_zero⟩ + fast_instance% DFunLike.coe_injective.smulWithZero ⟨((⇑) : IncidenceAlgebra 𝕝 α → α → α → 𝕝), coe_zero⟩ coe_constSMul instance moduleRight [Preorder α] [Semiring 𝕜] [AddCommMonoid 𝕝] [Module 𝕜 𝕝] : Module 𝕜 (IncidenceAlgebra 𝕝 α) := - DFunLike.coe_injective.module _ ⟨⟨((⇑) : IncidenceAlgebra 𝕝 α → α → α → 𝕝), coe_zero⟩, coe_add⟩ + fast_instance% DFunLike.coe_injective.module _ ⟨⟨((⇑) : IncidenceAlgebra 𝕝 α → α → α → 𝕝), coe_zero⟩, coe_add⟩ coe_constSMul instance algebraRight [PartialOrder α] [LocallyFiniteOrder α] [DecidableEq α] [CommSemiring 𝕜] diff --git a/Mathlib/Combinatorics/SimpleGraph/Dart.lean b/Mathlib/Combinatorics/SimpleGraph/Dart.lean index 651455db64474c..8312225aefda41 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Dart.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Dart.lean @@ -53,7 +53,7 @@ theorem Dart.toProd_injective : Function.Injective (Dart.toProd : G.Dart → V Dart.ext instance Dart.fintype [Fintype V] [DecidableRel G.Adj] : Fintype G.Dart := - Fintype.ofEquiv (Σ v, G.neighborSet v) + fast_instance% Fintype.ofEquiv (Σ v, G.neighborSet v) { toFun := fun s => ⟨(s.fst, s.snd), s.snd.property⟩ invFun := fun d => ⟨d.fst, d.snd, d.adj⟩ } diff --git a/Mathlib/Combinatorics/SimpleGraph/Finite.lean b/Mathlib/Combinatorics/SimpleGraph/Finite.lean index e67cc079450575..c4971c8018512f 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Finite.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Finite.lean @@ -258,7 +258,7 @@ theorem degree_compl [Fintype (Gᶜ.neighborSet v)] [Fintype V] : simp [card_union_of_disjoint (Set.disjoint_toFinset.mpr (compl_neighborSet_disjoint G v))] instance incidenceSetFintype [DecidableEq V] : Fintype (G.incidenceSet v) := - Fintype.ofEquiv (G.neighborSet v) (G.incidenceSetEquivNeighborSet v).symm + fast_instance% Fintype.ofEquiv (G.neighborSet v) (G.incidenceSetEquivNeighborSet v).symm /-- This is the `Finset` version of `incidenceSet`. -/ def incidenceFinset [DecidableEq V] : Finset (Sym2 V) := diff --git a/Mathlib/Combinatorics/SimpleGraph/Finsubgraph.lean b/Mathlib/Combinatorics/SimpleGraph/Finsubgraph.lean index 41eeb98124fe6b..0fe5a31c7b717b 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Finsubgraph.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Finsubgraph.lean @@ -80,7 +80,7 @@ lemma coe_inf (G₁ G₂ : G.Finsubgraph) : ↑(G₁ ⊓ G₂) = (G₁ ⊓ G₂ lemma coe_sdiff (G₁ G₂ : G.Finsubgraph) : ↑(G₁ \ G₂) = (G₁ \ G₂ : G.Subgraph) := rfl instance instGeneralizedCoheytingAlgebra : GeneralizedCoheytingAlgebra G.Finsubgraph := - Subtype.coe_injective.generalizedCoheytingAlgebra _ .rfl .rfl coe_sup coe_inf coe_bot coe_sdiff + fast_instance% Subtype.coe_injective.generalizedCoheytingAlgebra _ .rfl .rfl coe_sup coe_inf coe_bot coe_sdiff section Finite variable [Finite V] @@ -114,7 +114,7 @@ lemma coe_iInf {ι : Sort*} (f : ι → G.Finsubgraph) : ⨅ i, f i = (⨅ i, f rw [iInf, coe_sInf, iInf_range] instance instCompletelyDistribLattice : CompletelyDistribLattice G.Finsubgraph := - Subtype.coe_injective.completelyDistribLattice _ .rfl .rfl coe_sup coe_inf coe_sSup coe_sInf + fast_instance% Subtype.coe_injective.completelyDistribLattice _ .rfl .rfl coe_sup coe_inf coe_sSup coe_sInf coe_top coe_bot coe_compl coe_himp coe_hnot coe_sdiff end Finite diff --git a/Mathlib/Combinatorics/SimpleGraph/Prod.lean b/Mathlib/Combinatorics/SimpleGraph/Prod.lean index 73dbe0f5641415..6948fee922ba18 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Prod.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Prod.lean @@ -230,7 +230,7 @@ theorem connected_boxProd : (G □ H).Connected ↔ G.Connected ∧ H.Connected instance boxProdFintypeNeighborSet (x : α × β) [Fintype (G.neighborSet x.1)] [Fintype (H.neighborSet x.2)] : Fintype ((G □ H).neighborSet x) := - Fintype.ofEquiv + fast_instance% Fintype.ofEquiv ((G.neighborFinset x.1 ×ˢ {x.2}).disjUnion ({x.1} ×ˢ H.neighborFinset x.2) <| Finset.disjoint_product.mpr <| Or.inl <| neighborFinset_disjoint_singleton _ _) ((Equiv.refl _).subtypeEquiv fun y => by diff --git a/Mathlib/Combinatorics/SimpleGraph/Subgraph.lean b/Mathlib/Combinatorics/SimpleGraph/Subgraph.lean index 0b71a3f1559e06..f983e2626bf075 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Subgraph.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Subgraph.lean @@ -787,7 +787,7 @@ instance (G' : Subgraph G) [Fintype G'.verts] (v : V) [DecidablePred (· ∈ G'. instance coeFiniteAt {G' : Subgraph G} (v : G'.verts) [Fintype (G'.neighborSet v)] : Fintype (G'.coe.neighborSet v) := - Fintype.ofEquiv _ (coeNeighborSetEquiv v).symm + fast_instance% Fintype.ofEquiv _ (coeNeighborSetEquiv v).symm theorem IsSpanning.card_verts [Fintype V] {G' : Subgraph G} [Fintype G'.verts] (h : G'.IsSpanning) : G'.verts.toFinset.card = Fintype.card V := by diff --git a/Mathlib/Combinatorics/Young/YoungDiagram.lean b/Mathlib/Combinatorics/Young/YoungDiagram.lean index df7fa4f351b824..8e09a228be3077 100644 --- a/Mathlib/Combinatorics/Young/YoungDiagram.lean +++ b/Mathlib/Combinatorics/Young/YoungDiagram.lean @@ -171,7 +171,7 @@ instance : Inhabited YoungDiagram := ⟨⊥⟩ instance : DistribLattice YoungDiagram := - Function.Injective.distribLattice YoungDiagram.cells (fun μ ν h ↦ by rwa [YoungDiagram.ext_iff]) + fast_instance% Function.Injective.distribLattice YoungDiagram.cells (fun μ ν h ↦ by rwa [YoungDiagram.ext_iff]) .rfl .rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl end DistribLattice diff --git a/Mathlib/Computability/TuringMachine/Tape.lean b/Mathlib/Computability/TuringMachine/Tape.lean index 22ad98a2f1fb51..80fdbde67f7dd7 100644 --- a/Mathlib/Computability/TuringMachine/Tape.lean +++ b/Mathlib/Computability/TuringMachine/Tape.lean @@ -11,6 +11,7 @@ public import Mathlib.Data.List.GetD public import Mathlib.Algebra.Group.Int.Defs public import Mathlib.Algebra.Group.Nat.Defs public import Mathlib.Data.List.Basic +public import Mathlib.Tactic.FastInstance /-! # Turing machine tapes @@ -126,10 +127,10 @@ def ListBlank (Γ) [Inhabited Γ] := Quotient (BlankRel.setoid Γ) instance ListBlank.inhabited {Γ} [Inhabited Γ] : Inhabited (ListBlank Γ) := - ⟨Quotient.mk'' []⟩ + fast_instance% ⟨Quotient.mk'' []⟩ instance ListBlank.hasEmptyc {Γ} [Inhabited Γ] : EmptyCollection (ListBlank Γ) := - ⟨Quotient.mk'' []⟩ + fast_instance% ⟨Quotient.mk'' []⟩ /-- A modified version of `Quotient.liftOn'` specialized for `ListBlank`, with the stronger precondition `BlankExtends` instead of `BlankRel`. -/ diff --git a/Mathlib/Data/DFinsupp/Defs.lean b/Mathlib/Data/DFinsupp/Defs.lean index dfc8cf7346c197..013ceb33e347ea 100644 --- a/Mathlib/Data/DFinsupp/Defs.lean +++ b/Mathlib/Data/DFinsupp/Defs.lean @@ -195,7 +195,7 @@ theorem coe_add [∀ i, AddZeroClass (β i)] (g₁ g₂ : Π₀ i, β i) : ⇑(g rfl instance addZeroClass [∀ i, AddZeroClass (β i)] : AddZeroClass (Π₀ i, β i) := - DFunLike.coe_injective.addZeroClass _ coe_zero coe_add + fast_instance% DFunLike.coe_injective.addZeroClass _ coe_zero coe_add instance instIsLeftCancelAdd [∀ i, AddZeroClass (β i)] [∀ i, IsLeftCancelAdd (β i)] : IsLeftCancelAdd (Π₀ i, β i) where @@ -221,7 +221,7 @@ theorem coe_nsmul [∀ i, AddMonoid (β i)] (b : ℕ) (v : Π₀ i, β i) : ⇑( rfl instance [∀ i, AddMonoid (β i)] : AddMonoid (Π₀ i, β i) := - DFunLike.coe_injective.addMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _ + fast_instance% DFunLike.coe_injective.addMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _ /-- Coercion from a `DFinsupp` to a pi type is an `AddMonoidHom`. -/ def coeFnAddMonoidHom [∀ i, AddZeroClass (β i)] : (Π₀ i, β i) →+ ∀ i, β i where @@ -234,7 +234,7 @@ lemma coeFnAddMonoidHom_apply [∀ i, AddZeroClass (β i)] (v : Π₀ i, β i) : rfl instance addCommMonoid [∀ i, AddCommMonoid (β i)] : AddCommMonoid (Π₀ i, β i) := - DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _ + fast_instance% DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _ instance [∀ i, AddGroup (β i)] : Neg (Π₀ i, β i) := ⟨fun f => f.mapRange (fun _ => Neg.neg) fun _ => neg_zero⟩ @@ -267,11 +267,11 @@ theorem coe_zsmul [∀ i, AddGroup (β i)] (b : ℤ) (v : Π₀ i, β i) : ⇑(b rfl instance [∀ i, AddGroup (β i)] : AddGroup (Π₀ i, β i) := - DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _) + fast_instance% DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _) fun _ _ => coe_zsmul _ _ instance addCommGroup [∀ i, AddCommGroup (β i)] : AddCommGroup (Π₀ i, β i) := - DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _) + fast_instance% DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _) fun _ _ => coe_zsmul _ _ end Algebra @@ -424,10 +424,10 @@ theorem mk_injective (s : Finset ι) : Function.Injective (@mk ι β _ _ s) := b end DecidableEq instance unique [∀ i, Subsingleton (β i)] : Unique (Π₀ i, β i) := - DFunLike.coe_injective.unique + fast_instance% DFunLike.coe_injective.unique instance uniqueOfIsEmpty [IsEmpty ι] : Unique (Π₀ i, β i) := - DFunLike.coe_injective.unique + fast_instance% DFunLike.coe_injective.unique /-- Given `Fintype ι`, `equivFunOnFintype` is the `Equiv` between `Π₀ i, β i` and `Π i, β i`. (All dependent functions on a finite type are finitely supported.) -/ diff --git a/Mathlib/Data/DFinsupp/FiniteInfinite.lean b/Mathlib/Data/DFinsupp/FiniteInfinite.lean index a1efaa0e13f44d..210eb3ec76a285 100644 --- a/Mathlib/Data/DFinsupp/FiniteInfinite.lean +++ b/Mathlib/Data/DFinsupp/FiniteInfinite.lean @@ -30,7 +30,7 @@ section FiniteInfinite instance DFinsupp.fintype {ι : Sort _} {π : ι → Sort _} [DecidableEq ι] [∀ i, Zero (π i)] [Fintype ι] [∀ i, Fintype (π i)] : Fintype (Π₀ i, π i) := - Fintype.ofEquiv (∀ i, π i) DFinsupp.equivFunOnFintype.symm + fast_instance% Fintype.ofEquiv (∀ i, π i) DFinsupp.equivFunOnFintype.symm instance DFinsupp.infinite_of_left {ι : Sort _} {π : ι → Sort _} [∀ i, Nontrivial (π i)] [∀ i, Zero (π i)] [Infinite ι] : Infinite (Π₀ i, π i) := by diff --git a/Mathlib/Data/DFinsupp/Module.lean b/Mathlib/Data/DFinsupp/Module.lean index 20aa2e99b440eb..5dd1417ce0eb9f 100644 --- a/Mathlib/Data/DFinsupp/Module.lean +++ b/Mathlib/Data/DFinsupp/Module.lean @@ -62,7 +62,7 @@ instance isCentralScalar [∀ i, Zero (β i)] [∀ i, SMulZeroClass γ (β i)] structure on each coordinate. -/ instance distribMulAction [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] : DistribMulAction γ (Π₀ i, β i) := - Function.Injective.distribMulAction coeFnAddMonoidHom DFunLike.coe_injective coe_smul + fast_instance% Function.Injective.distribMulAction coeFnAddMonoidHom DFunLike.coe_injective coe_smul /-- Dependent functions with finite support inherit a module structure from such a structure on each coordinate. -/ diff --git a/Mathlib/Data/DList/Instances.lean b/Mathlib/Data/DList/Instances.lean index d2d89ffc6a26c0..386ddf0e352712 100644 --- a/Mathlib/Data/DList/Instances.lean +++ b/Mathlib/Data/DList/Instances.lean @@ -34,7 +34,7 @@ def DList.listEquivDList : List α ≃ DList α where right_inv _ := DList.ofList_toList _ instance : Traversable DList := - Equiv.traversable DList.listEquivDList + fast_instance% Equiv.traversable DList.listEquivDList instance : LawfulTraversable DList := Equiv.isLawfulTraversable DList.listEquivDList diff --git a/Mathlib/Data/Finsupp/Basic.lean b/Mathlib/Data/Finsupp/Basic.lean index 682adeef183b67..3e584dd74edb33 100644 --- a/Mathlib/Data/Finsupp/Basic.lean +++ b/Mathlib/Data/Finsupp/Basic.lean @@ -1164,11 +1164,11 @@ variable [Zero R] /-- The `Finsupp` version of `Pi.unique`. -/ instance uniqueOfRight [Subsingleton R] : Unique (α →₀ R) := - DFunLike.coe_injective.unique + fast_instance% DFunLike.coe_injective.unique /-- The `Finsupp` version of `Pi.uniqueOfIsEmpty`. -/ instance uniqueOfLeft [IsEmpty α] : Unique (α →₀ R) := - DFunLike.coe_injective.unique + fast_instance% DFunLike.coe_injective.unique end diff --git a/Mathlib/Data/Finsupp/Fintype.lean b/Mathlib/Data/Finsupp/Fintype.lean index 29736c74da1e94..f243c05e128249 100644 --- a/Mathlib/Data/Finsupp/Fintype.lean +++ b/Mathlib/Data/Finsupp/Fintype.lean @@ -21,7 +21,7 @@ public section variable {ι α : Type*} [DecidableEq ι] [Fintype ι] [Zero α] [Fintype α] noncomputable instance Finsupp.fintype : Fintype (ι →₀ α) := - Fintype.ofEquiv _ Finsupp.equivFunOnFinite.symm + fast_instance% Fintype.ofEquiv _ Finsupp.equivFunOnFinite.symm instance Finsupp.infinite_of_left [Nontrivial α] [Infinite ι] : Infinite (ι →₀ α) := let ⟨_, hm⟩ := exists_ne (0 : α) diff --git a/Mathlib/Data/Finsupp/Pointwise.lean b/Mathlib/Data/Finsupp/Pointwise.lean index 0fb88d8fbe9e11..d943ef734bf8d8 100644 --- a/Mathlib/Data/Finsupp/Pointwise.lean +++ b/Mathlib/Data/Finsupp/Pointwise.lean @@ -67,32 +67,32 @@ theorem support_mul [DecidableEq α] {g₁ g₂ : α →₀ β} : subset_inter support_mul_subset_left support_mul_subset_right instance : MulZeroClass (α →₀ β) := - DFunLike.coe_injective.mulZeroClass _ coe_zero coe_mul + fast_instance% DFunLike.coe_injective.mulZeroClass _ coe_zero coe_mul end instance [SemigroupWithZero β] : SemigroupWithZero (α →₀ β) := - DFunLike.coe_injective.semigroupWithZero _ coe_zero coe_mul + fast_instance% DFunLike.coe_injective.semigroupWithZero _ coe_zero coe_mul instance [NonUnitalNonAssocSemiring β] : NonUnitalNonAssocSemiring (α →₀ β) := - DFunLike.coe_injective.nonUnitalNonAssocSemiring _ coe_zero coe_add coe_mul fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.nonUnitalNonAssocSemiring _ coe_zero coe_add coe_mul fun _ _ ↦ rfl instance [NonUnitalSemiring β] : NonUnitalSemiring (α →₀ β) := - DFunLike.coe_injective.nonUnitalSemiring _ coe_zero coe_add coe_mul fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.nonUnitalSemiring _ coe_zero coe_add coe_mul fun _ _ ↦ rfl instance [NonUnitalCommSemiring β] : NonUnitalCommSemiring (α →₀ β) := - DFunLike.coe_injective.nonUnitalCommSemiring _ coe_zero coe_add coe_mul fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.nonUnitalCommSemiring _ coe_zero coe_add coe_mul fun _ _ ↦ rfl instance [NonUnitalNonAssocRing β] : NonUnitalNonAssocRing (α →₀ β) := - DFunLike.coe_injective.nonUnitalNonAssocRing _ coe_zero coe_add coe_mul coe_neg coe_sub + fast_instance% DFunLike.coe_injective.nonUnitalNonAssocRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance [NonUnitalRing β] : NonUnitalRing (α →₀ β) := - DFunLike.coe_injective.nonUnitalRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ ↦ rfl) + fast_instance% DFunLike.coe_injective.nonUnitalRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance [NonUnitalCommRing β] : NonUnitalCommRing (α →₀ β) := - DFunLike.coe_injective.nonUnitalCommRing _ coe_zero coe_add coe_mul coe_neg coe_sub + fast_instance% DFunLike.coe_injective.nonUnitalCommRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ ↦ rfl) fun _ _ ↦ rfl lemma pointwise_smul_support_finite [Zero γ] [SMulZeroClass β γ] (f : α → β) @@ -115,7 +115,7 @@ theorem coe_pointwise_smul [Semiring β] (f : α → β) (g : α →₀ β) : /-- The pointwise multiplicative action of functions on finitely supported functions -/ instance pointwiseModule [Semiring β] : Module (α → β) (α →₀ β) := - Function.Injective.module _ coeFnAddHom DFunLike.coe_injective coe_pointwise_smul + fast_instance% Function.Injective.module _ coeFnAddHom DFunLike.coe_injective coe_pointwise_smul instance [Semiring β] : IsScalarTower β (α → β) (α →₀ β) where smul_assoc r f m := by ext; simp [mul_assoc] diff --git a/Mathlib/Data/Fintype/Basic.lean b/Mathlib/Data/Fintype/Basic.lean index 67f724a64a660c..6ae31f67a262f1 100644 --- a/Mathlib/Data/Fintype/Basic.lean +++ b/Mathlib/Data/Fintype/Basic.lean @@ -158,17 +158,17 @@ def Fintype.prodRight {α β} [DecidableEq β] [Fintype (α × β)] [Nonempty α ⟨(@univ (α × β) _).image Prod.snd, fun b => by simp⟩ instance ULift.fintype (α : Type*) [Fintype α] : Fintype (ULift α) := - Fintype.ofEquiv _ Equiv.ulift.symm + fast_instance% Fintype.ofEquiv _ Equiv.ulift.symm instance PLift.fintype (α : Type*) [Fintype α] : Fintype (PLift α) := - Fintype.ofEquiv _ Equiv.plift.symm + fast_instance% Fintype.ofEquiv _ Equiv.plift.symm instance PLift.fintypeProp (p : Prop) [Decidable p] : Fintype (PLift p) := ⟨if h : p then {⟨h⟩} else ∅, fun ⟨h⟩ => by simp [h]⟩ instance Quotient.fintype [Fintype α] (s : Setoid α) [DecidableRel ((· ≈ ·) : α → α → Prop)] : Fintype (Quotient s) := - Fintype.ofSurjective Quotient.mk'' Quotient.mk''_surjective + fast_instance% Fintype.ofSurjective Quotient.mk'' Quotient.mk''_surjective instance PSigma.fintypePropLeft {α : Prop} {β : α → Type*} [Decidable α] [∀ a, Fintype (β a)] : Fintype (Σ' a, β a) := @@ -177,7 +177,7 @@ instance PSigma.fintypePropLeft {α : Prop} {β : α → Type*} [Decidable α] [ instance PSigma.fintypePropRight {α : Type*} {β : α → Prop} [∀ a, Decidable (β a)] [Fintype α] : Fintype (Σ' a, β a) := - Fintype.ofEquiv { a // β a } + fast_instance% Fintype.ofEquiv { a // β a } ⟨fun ⟨x, y⟩ => ⟨x, y⟩, fun ⟨x, y⟩ => ⟨x, y⟩, fun ⟨_, _⟩ => rfl, fun ⟨_, _⟩ => rfl⟩ instance PSigma.fintypePropProp {α : Prop} {β : α → Prop} [Decidable α] [∀ a, Decidable (β a)] : diff --git a/Mathlib/Data/Fintype/Pi.lean b/Mathlib/Data/Fintype/Pi.lean index ff970b9c1b4ac9..1c5ee90301992b 100644 --- a/Mathlib/Data/Fintype/Pi.lean +++ b/Mathlib/Data/Fintype/Pi.lean @@ -153,7 +153,7 @@ noncomputable instance _root_.Function.Embedding.fintype {α β} [Fintype α] [F instance RelHom.instFintype {α β} [Fintype α] [Fintype β] [DecidableEq α] {r : α → α → Prop} {s : β → β → Prop} [DecidableRel r] [DecidableRel s] : Fintype (r →r s) := - Fintype.ofEquiv {f : α → β // ∀ {x y}, r x y → s (f x) (f y)} <| Equiv.mk + fast_instance% Fintype.ofEquiv {f : α → β // ∀ {x y}, r x y → s (f x) (f y)} <| Equiv.mk (fun f ↦ ⟨f.1, f.2⟩) (fun f ↦ ⟨f.1, f.2⟩) (fun _ ↦ rfl) (fun _ ↦ rfl) noncomputable instance RelEmbedding.instFintype {α β} [Fintype α] [Fintype β] diff --git a/Mathlib/Data/Fintype/Sigma.lean b/Mathlib/Data/Fintype/Sigma.lean index bad625b1368190..f1fee898bc5037 100644 --- a/Mathlib/Data/Fintype/Sigma.lean +++ b/Mathlib/Data/Fintype/Sigma.lean @@ -41,6 +41,6 @@ lemma Set.biInter_finsetSigma_univ' (s : Finset ι) (f : Π i, κ i → Set α) variable [Fintype ι] instance Sigma.instFintype : Fintype (Σ i, κ i) := ⟨univ.sigma fun _ ↦ univ, by simp⟩ -instance PSigma.instFintype : Fintype (Σ' i, κ i) := .ofEquiv _ (Equiv.psigmaEquivSigma _).symm +instance PSigma.instFintype : Fintype (Σ' i, κ i) := fast_instance% .ofEquiv _ (Equiv.psigmaEquivSigma _).symm @[simp] lemma Finset.univ_sigma_univ : univ.sigma (fun _ ↦ univ) = (univ : Finset (Σ i, κ i)) := rfl diff --git a/Mathlib/Data/Fintype/Units.lean b/Mathlib/Data/Fintype/Units.lean index 4ae54673d00fab..8337c4fc93bb5a 100644 --- a/Mathlib/Data/Fintype/Units.lean +++ b/Mathlib/Data/Fintype/Units.lean @@ -31,7 +31,7 @@ theorem UnitsInt.univ : (Finset.univ : Finset ℤˣ) = {1, -1} := rfl theorem Fintype.card_units_int : Fintype.card ℤˣ = 2 := rfl instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ := - Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm + fast_instance% Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm instance [Monoid α] [Finite α] : Finite αˣ := .of_injective _ Units.val_injective diff --git a/Mathlib/Data/Multiset/Fintype.lean b/Mathlib/Data/Multiset/Fintype.lean index e447b437ff83b2..3a4b606e7205bf 100644 --- a/Mathlib/Data/Multiset/Fintype.lean +++ b/Mathlib/Data/Multiset/Fintype.lean @@ -171,7 +171,7 @@ theorem toEmbedding_coeEquiv_trans (m : Multiset α) : m.coeEquiv.toEmbedding.trans (Function.Embedding.subtype _) = m.coeEmbedding := by ext <;> rfl instance fintypeCoe : Fintype m := - Fintype.ofEquiv m.toEnumFinset m.coeEquiv.symm + fast_instance% Fintype.ofEquiv m.toEnumFinset m.coeEquiv.symm attribute [irreducible] fintypeCoe diff --git a/Mathlib/Data/Sym/Basic.lean b/Mathlib/Data/Sym/Basic.lean index df918acd8a60df..ca6776b70d1454 100644 --- a/Mathlib/Data/Sym/Basic.lean +++ b/Mathlib/Data/Sym/Basic.lean @@ -316,7 +316,7 @@ instance inhabitedSym [Inhabited α] (n : ℕ) : Inhabited (Sym α n) := ⟨replicate n default⟩ instance inhabitedSym' [Inhabited α] (n : ℕ) : Inhabited (Sym' α n) := - ⟨Quotient.mk' (List.Vector.replicate n default)⟩ + fast_instance% ⟨Quotient.mk' (List.Vector.replicate n default)⟩ instance (n : ℕ) [IsEmpty α] : IsEmpty (Sym α n.succ) := ⟨fun s => by diff --git a/Mathlib/FieldTheory/Galois/GaloisClosure.lean b/Mathlib/FieldTheory/Galois/GaloisClosure.lean index b08c80a7d8ed8a..094cca16e206de 100644 --- a/Mathlib/FieldTheory/Galois/GaloisClosure.lean +++ b/Mathlib/FieldTheory/Galois/GaloisClosure.lean @@ -88,7 +88,7 @@ instance : Min (FiniteGaloisIntermediateField k K) where min L₁ L₂ := .mk <| L₁ ⊓ L₂ instance : PartialOrder (FiniteGaloisIntermediateField k K) := - PartialOrder.lift _ val_injective + fast_instance% PartialOrder.lift _ val_injective instance : Lattice (FiniteGaloisIntermediateField k K) := val_injective.lattice _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) diff --git a/Mathlib/Geometry/Diffeology/Basic.lean b/Mathlib/Geometry/Diffeology/Basic.lean index 8262d574912185..1a3c0dbdd55654 100644 --- a/Mathlib/Geometry/Diffeology/Basic.lean +++ b/Mathlib/Geometry/Diffeology/Basic.lean @@ -495,7 +495,7 @@ lemma isPlot_generatedFrom_of_mem {g : Set ((n : ℕ) × (𝔼ⁿ → X))} {n : (hp : ⟨n, p⟩ ∈ g) : (@IsPlot _ (generateFrom g)) p := self_subset_toPlots_generateFrom g hp -instance : PartialOrder (DiffeologicalSpace X) := PartialOrder.lift _ injective_toPlots +instance : PartialOrder (DiffeologicalSpace X) := fast_instance% PartialOrder.lift _ injective_toPlots lemma le_def {d₁ d₂ : DiffeologicalSpace X} : d₁ ≤ d₂ ↔ d₁.toPlots ⊆ d₂.toPlots := Iff.rfl diff --git a/Mathlib/Geometry/Manifold/Algebra/SmoothFunctions.lean b/Mathlib/Geometry/Manifold/Algebra/SmoothFunctions.lean index 57cf480babcd27..4e317e97ae27ed 100644 --- a/Mathlib/Geometry/Manifold/Algebra/SmoothFunctions.lean +++ b/Mathlib/Geometry/Manifold/Algebra/SmoothFunctions.lean @@ -82,12 +82,12 @@ under pointwise multiplication. @[to_additive] instance semigroup {G : Type*} [Semigroup G] [TopologicalSpace G] [ChartedSpace H' G] [ContMDiffMul I' n G] : Semigroup C^n⟮I, N; I', G⟯ := - DFunLike.coe_injective.semigroup _ coe_mul + fast_instance% DFunLike.coe_injective.semigroup _ coe_mul @[to_additive] instance monoid {G : Type*} [Monoid G] [TopologicalSpace G] [ChartedSpace H' G] [ContMDiffMul I' n G] : Monoid C^n⟮I, N; I', G⟯ := - DFunLike.coe_injective.monoid _ coe_one coe_mul coe_pow + fast_instance% DFunLike.coe_injective.monoid _ coe_one coe_mul coe_pow /-- Coercion to a function as a `MonoidHom`. Similar to `MonoidHom.coeFn`. -/ @[to_additive (attr := simps) /-- Coercion to a function as an `AddMonoidHom`. @@ -131,7 +131,7 @@ variable {I I'} @[to_additive] instance commMonoid {G : Type*} [CommMonoid G] [TopologicalSpace G] [ChartedSpace H' G] [ContMDiffMul I' n G] : CommMonoid C^n⟮I, N; I', G⟯ := - DFunLike.coe_injective.commMonoid _ coe_one coe_mul coe_pow + fast_instance% DFunLike.coe_injective.commMonoid _ coe_one coe_mul coe_pow @[to_additive] instance group {G : Type*} [Group G] [TopologicalSpace G] [ChartedSpace H' G] [LieGroup I' n G] : @@ -250,7 +250,7 @@ theorem smul_comp {V : Type*} [NormedAddCommGroup V] [NormedSpace 𝕜 V] (r : instance module {V : Type*} [NormedAddCommGroup V] [NormedSpace 𝕜 V] : Module 𝕜 C^n⟮I, N; 𝓘(𝕜, V), V⟯ := - Function.Injective.module 𝕜 coeFnAddMonoidHom ContMDiffMap.coe_injective coe_smul + fast_instance% Function.Injective.module 𝕜 coeFnAddMonoidHom ContMDiffMap.coe_injective coe_smul /-- Coercion to a function as a `LinearMap`. -/ @[simps] diff --git a/Mathlib/Geometry/Manifold/StructureGroupoid.lean b/Mathlib/Geometry/Manifold/StructureGroupoid.lean index 31f9f8ab53e866..517d7f59ce3f93 100644 --- a/Mathlib/Geometry/Manifold/StructureGroupoid.lean +++ b/Mathlib/Geometry/Manifold/StructureGroupoid.lean @@ -183,7 +183,7 @@ theorem StructureGroupoid.mem_iff_of_eqOnSource {G : StructureGroupoid H} /-- Partial order on the set of groupoids, given by inclusion of the members of the groupoid. -/ instance StructureGroupoid.partialOrder : PartialOrder (StructureGroupoid H) := - PartialOrder.lift StructureGroupoid.members fun a b h ↦ by + fast_instance% PartialOrder.lift StructureGroupoid.members fun a b h ↦ by cases a cases b dsimp at h diff --git a/Mathlib/GroupTheory/Congruence/Defs.lean b/Mathlib/GroupTheory/Congruence/Defs.lean index bccc97265324aa..6c5e0ba4f576f2 100644 --- a/Mathlib/GroupTheory/Congruence/Defs.lean +++ b/Mathlib/GroupTheory/Congruence/Defs.lean @@ -579,7 +579,7 @@ instance commMagma {M : Type*} [CommMagma M] (c : Con M) : CommMagma c.Quotient @[to_additive /-- The quotient of an `AddCommSemigroup` by an additive congruence relation is an `AddCommSemigroup`. -/] instance commSemigroup {M : Type*} [CommSemigroup M] (c : Con M) : CommSemigroup c.Quotient := - Function.Surjective.commSemigroup _ Quotient.mk''_surjective fun _ _ => rfl + fast_instance% Function.Surjective.commSemigroup _ Quotient.mk''_surjective fun _ _ => rfl /-- The quotient of a monoid by a congruence relation is a monoid. -/ @[to_additive /-- The quotient of an `AddMonoid` by an additive congruence relation is diff --git a/Mathlib/GroupTheory/GroupAction/ConjAct.lean b/Mathlib/GroupTheory/GroupAction/ConjAct.lean index f6243e6eabcb82..d9442ed24b0baa 100644 --- a/Mathlib/GroupTheory/GroupAction/ConjAct.lean +++ b/Mathlib/GroupTheory/GroupAction/ConjAct.lean @@ -241,7 +241,7 @@ theorem Subgroup.val_conj_smul {H : Subgroup G} [H.Normal] (g : ConjAct G) (h : instance Subgroup.conjMulDistribMulAction {H : Subgroup G} [H.Normal] : MulDistribMulAction (ConjAct G) H := - Subtype.coe_injective.mulDistribMulAction H.subtype Subgroup.val_conj_smul + fast_instance% Subtype.coe_injective.mulDistribMulAction H.subtype Subgroup.val_conj_smul /-- Group conjugation on a normal subgroup. Analogous to `MulAut.conj`. -/ def _root_.MulAut.conjNormal {H : Subgroup G} [H.Normal] : G →* MulAut H := diff --git a/Mathlib/GroupTheory/GroupAction/DomAct/ActionHom.lean b/Mathlib/GroupTheory/GroupAction/DomAct/ActionHom.lean index a007f458aef92a..e4e43bc9df018c 100644 --- a/Mathlib/GroupTheory/GroupAction/DomAct/ActionHom.lean +++ b/Mathlib/GroupTheory/GroupAction/DomAct/ActionHom.lean @@ -49,7 +49,7 @@ end SMul instance {M α N β : Type*} [Monoid M] [MulAction M α] [SMul N α] [SMulCommClass M N α] [SMul N β] : MulAction Mᵈᵐᵃ (α →[N] β) := - DFunLike.coe_injective.mulAction _ fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.mulAction _ fun _ _ ↦ rfl end MulActionSemiHom @@ -80,7 +80,7 @@ end SMul instance {M N A B : Type*} [Monoid M] [AddMonoid A] [DistribMulAction M A] [Monoid N] [AddMonoid B] [DistribMulAction N A] [SMulCommClass M N A] [DistribMulAction N B] : MulAction Mᵈᵐᵃ (A →+[N] B) := - DFunLike.coe_injective.mulAction _ fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.mulAction _ fun _ _ ↦ rfl end DistribMulActionHom diff --git a/Mathlib/GroupTheory/GroupAction/DomAct/Basic.lean b/Mathlib/GroupTheory/GroupAction/DomAct/Basic.lean index 3e8b3da14ed0d0..7c2cecc301d04c 100644 --- a/Mathlib/GroupTheory/GroupAction/DomAct/Basic.lean +++ b/Mathlib/GroupTheory/GroupAction/DomAct/Basic.lean @@ -223,7 +223,7 @@ theorem smul_monoidHom_apply (c : Mᵈᵐᵃ) (f : A →* B) (a : A) : (c • f) @[simp] theorem mk_smul_monoidHom_apply (c : M) (f : A →* B) (a : A) : (mk c • f) a = f (c • a) := rfl -instance : MulAction Mᵈᵐᵃ (A →* B) := DFunLike.coe_injective.mulAction (⇑) fun _ _ ↦ rfl +instance : MulAction Mᵈᵐᵃ (A →* B) := fast_instance% DFunLike.coe_injective.mulAction (⇑) fun _ _ ↦ rfl end MonoidHom @@ -256,15 +256,15 @@ end DistribSMul variable {A M B : Type*} instance [Monoid M] [AddMonoid A] [DistribMulAction M A] [AddZeroClass B] : - MulAction Mᵈᵐᵃ (A →+ B) := DFunLike.coe_injective.mulAction (⇑) fun _ _ ↦ rfl + MulAction Mᵈᵐᵃ (A →+ B) := fast_instance% DFunLike.coe_injective.mulAction (⇑) fun _ _ ↦ rfl instance [Monoid M] [AddMonoid A] [DistribMulAction M A] [AddCommMonoid B] : DistribMulAction Mᵈᵐᵃ (A →+ B) := - DFunLike.coe_injective.distribMulAction (AddMonoidHom.coeFn A B) fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.distribMulAction (AddMonoidHom.coeFn A B) fun _ _ ↦ rfl instance [Monoid M] [Monoid A] [MulDistribMulAction M A] [CommMonoid B] : MulDistribMulAction Mᵈᵐᵃ (A →* B) := - DFunLike.coe_injective.mulDistribMulAction (MonoidHom.coeFn A B) fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.mulDistribMulAction (MonoidHom.coeFn A B) fun _ _ ↦ rfl end AddMonoidHom diff --git a/Mathlib/GroupTheory/GroupAction/Embedding.lean b/Mathlib/GroupTheory/GroupAction/Embedding.lean index 65999da1759678..c91b877ffe430a 100644 --- a/Mathlib/GroupTheory/GroupAction/Embedding.lean +++ b/Mathlib/GroupTheory/GroupAction/Embedding.lean @@ -60,6 +60,6 @@ instance [Group G] [MulAction G β] [MulAction Gᵐᵒᵖ β] [IsCentralScalar G @[to_additive] instance [Group G] [MulAction G β] : MulAction G (α ↪ β) := - DFunLike.coe_injective.mulAction _ coe_smul + fast_instance% DFunLike.coe_injective.mulAction _ coe_smul end Function.Embedding diff --git a/Mathlib/GroupTheory/GroupAction/OfQuotient.lean b/Mathlib/GroupTheory/GroupAction/OfQuotient.lean index 6f50ef3f79e6d6..e39e99a65655c0 100644 --- a/Mathlib/GroupTheory/GroupAction/OfQuotient.lean +++ b/Mathlib/GroupTheory/GroupAction/OfQuotient.lean @@ -26,7 +26,7 @@ variable {G : Type*} [Group G] {A : Type*} [MulAction G A] variable {H : Subgroup G} [H.Normal] instance : MulAction (G ⧸ H) (fixedPoints H A) := - ofEndHom <| + fast_instance% ofEndHom <| QuotientGroup.lift H (toEndHom : G →* Function.End (fixedPoints H A)) (fun g hg ↦ by funext a; ext; exact a.2 ⟨g, hg⟩) diff --git a/Mathlib/GroupTheory/GroupAction/SubMulAction.lean b/Mathlib/GroupTheory/GroupAction/SubMulAction.lean index b2682823966efd..13401b201ff73d 100644 --- a/Mathlib/GroupTheory/GroupAction/SubMulAction.lean +++ b/Mathlib/GroupTheory/GroupAction/SubMulAction.lean @@ -271,7 +271,7 @@ instance : InfSet (SubMulAction R M) := @[to_additive] instance : CompleteLattice (SubMulAction R M) := - SetLike.coe_injective.completeLattice _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + fast_instance% SetLike.coe_injective.completeLattice _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) rfl rfl @[to_additive (attr := simp)] @@ -338,7 +338,7 @@ variable [hA : SMulMemClass A R M] (S' : A) /-- A `SubMulAction` of a `MulAction` is a `MulAction`. -/ @[to_additive /-- A `SubAddAction` of an `AddAction` is an `AddAction`. -/] instance (priority := 75) toMulAction : MulAction R S' := - Subtype.coe_injective.mulAction Subtype.val (SetLike.val_smul S') + fast_instance% Subtype.coe_injective.mulAction Subtype.val (SetLike.val_smul S') /-- The natural `MulActionHom` over `R` from a `SubMulAction` of `M` to `M`. -/ @[to_additive /-- The natural `AddActionHom` over `R` from a `SubAddAction` of `M` to `M`. -/] diff --git a/Mathlib/GroupTheory/Perm/Cycle/Type.lean b/Mathlib/GroupTheory/Perm/Cycle/Type.lean index 58cf7430a724ec..4a8dc5ace032c0 100644 --- a/Mathlib/GroupTheory/Perm/Cycle/Type.lean +++ b/Mathlib/GroupTheory/Perm/Cycle/Type.lean @@ -466,7 +466,7 @@ def equivVector : ∀ n, vectorsProdEqOne G n ≃ List.Vector G (n - 1) | (n + 1) => (vectorEquiv G n).symm instance [Fintype G] : Fintype (vectorsProdEqOne G n) := - Fintype.ofEquiv (List.Vector G (n - 1)) (equivVector G n).symm + fast_instance% Fintype.ofEquiv (List.Vector G (n - 1)) (equivVector G n).symm theorem card [Fintype G] : Fintype.card (vectorsProdEqOne G n) = Fintype.card G ^ (n - 1) := (Fintype.card_congr (equivVector G n)).trans (card_vector (n - 1)) diff --git a/Mathlib/GroupTheory/SpecificGroups/Dihedral.lean b/Mathlib/GroupTheory/SpecificGroups/Dihedral.lean index abea98a604b6d9..1773a46edcff36 100644 --- a/Mathlib/GroupTheory/SpecificGroups/Dihedral.lean +++ b/Mathlib/GroupTheory/SpecificGroups/Dihedral.lean @@ -145,7 +145,7 @@ def equivSum : DihedralGroup n ≃ (ZMod n) ⊕ (ZMod n) where /-- If `0 < n`, then `DihedralGroup n` is a finite group. -/ instance [NeZero n] : Fintype (DihedralGroup n) := - Fintype.ofEquiv _ equivSum.symm + fast_instance% Fintype.ofEquiv _ equivSum.symm instance : Infinite (DihedralGroup 0) := equivSum.symm.infinite_iff.mp inferInstance diff --git a/Mathlib/GroupTheory/SpecificGroups/Quaternion.lean b/Mathlib/GroupTheory/SpecificGroups/Quaternion.lean index cf44529992f105..898f588d914ad6 100644 --- a/Mathlib/GroupTheory/SpecificGroups/Quaternion.lean +++ b/Mathlib/GroupTheory/SpecificGroups/Quaternion.lean @@ -165,7 +165,7 @@ set_option backward.privateInPublic.warn false in /-- If `0 < n`, then `QuaternionGroup n` is a finite group. -/ instance [NeZero n] : Fintype (QuaternionGroup n) := - Fintype.ofEquiv _ fintypeHelper + fast_instance% Fintype.ofEquiv _ fintypeHelper instance : Nontrivial (QuaternionGroup n) := ⟨⟨a 0, xa 0, by simp [- a_zero]⟩⟩ diff --git a/Mathlib/LinearAlgebra/AffineSpace/Basis.lean b/Mathlib/LinearAlgebra/AffineSpace/Basis.lean index 5b78567a33ba69..e1804ad5af53e4 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/Basis.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/Basis.lean @@ -300,7 +300,7 @@ instance instVAdd : VAdd V (AffineBasis ι k P) where simp instance instAddAction : AddAction V (AffineBasis ι k P) := - DFunLike.coe_injective.addAction _ coe_vadd + fast_instance% DFunLike.coe_injective.addAction _ coe_vadd @[simp] lemma coord_vadd (v : V) (b : AffineBasis ι k P) : (v +ᵥ b).coord i = (b.coord i).comp (AffineEquiv.constVAdd k P v).symm := by @@ -354,7 +354,7 @@ instance [SMul G G'] [IsScalarTower G G' V] : IsScalarTower G G' (AffineBasis ι /-- TODO: generalize to include `SMul (P ≃ᵃ[k] P) (AffineBasis ι k P)`, which acts on `P` with a `VAdd` version of a `DistribMulAction`. -/ instance instMulAction : MulAction G (AffineBasis ι k V) := - DFunLike.coe_injective.mulAction _ coe_smul + fast_instance% DFunLike.coe_injective.mulAction _ coe_smul end SMul end Ring diff --git a/Mathlib/LinearAlgebra/Basis/SMul.lean b/Mathlib/LinearAlgebra/Basis/SMul.lean index 091b29649fb93c..06e916ddb63e92 100644 --- a/Mathlib/LinearAlgebra/Basis/SMul.lean +++ b/Mathlib/LinearAlgebra/Basis/SMul.lean @@ -56,7 +56,7 @@ theorem smul_eq_map (g : M ≃ₗ[R] M) (b : Basis ι R M) : g • b = b.map g : (g • b).repr = (DistribMulAction.toLinearEquiv _ _ g).symm.trans b.repr := rfl instance : MulAction G (Basis ι R M) := - Function.Injective.mulAction _ DFunLike.coe_injective coe_smul + fast_instance% Function.Injective.mulAction _ DFunLike.coe_injective coe_smul instance [SMulCommClass G G' M] : SMulCommClass G G' (Basis ι R M) where smul_comm _g _g' _b := DFunLike.ext _ _ fun _ => smul_comm _ _ _ diff --git a/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Defs.lean b/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Defs.lean index f232f6ec2639d7..20b7e7ad02baa7 100644 --- a/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Defs.lean +++ b/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Defs.lean @@ -348,7 +348,7 @@ theorem GLPos.coe_neg_apply (g : GLPos n R) (i j : n) : rfl instance : HasDistribNeg (GLPos n R) := - Subtype.coe_injective.hasDistribNeg _ GLPos.coe_neg_GL (GLPos n R).coe_mul + fast_instance% Subtype.coe_injective.hasDistribNeg _ GLPos.coe_neg_GL (GLPos n R).coe_mul end Neg diff --git a/Mathlib/LinearAlgebra/Matrix/SpecialLinearGroup.lean b/Mathlib/LinearAlgebra/Matrix/SpecialLinearGroup.lean index 4e3ba67f3014bf..d7c9c892831958 100644 --- a/Mathlib/LinearAlgebra/Matrix/SpecialLinearGroup.lean +++ b/Mathlib/LinearAlgebra/Matrix/SpecialLinearGroup.lean @@ -180,7 +180,7 @@ theorem row_ne_zero [Nontrivial R] (g : SpecialLinearGroup n R) (i : n) : g i end CoeLemmas instance monoid : Monoid (SpecialLinearGroup n R) := - Function.Injective.monoid _ Subtype.coe_injective coe_one coe_mul coe_pow + fast_instance% Function.Injective.monoid _ Subtype.coe_injective coe_one coe_mul coe_pow instance : Group (SpecialLinearGroup n R) := { SpecialLinearGroup.monoid, SpecialLinearGroup.hasInv with @@ -359,7 +359,7 @@ theorem coe_neg (g : SpecialLinearGroup n R) : ↑(-g) = -(g : Matrix n n R) := rfl instance : HasDistribNeg (SpecialLinearGroup n R) := - Function.Injective.hasDistribNeg _ Subtype.coe_injective coe_neg coe_mul + fast_instance% Function.Injective.hasDistribNeg _ Subtype.coe_injective coe_neg coe_mul @[simp] theorem coe_int_neg (g : SpecialLinearGroup n ℤ) : ↑(-g) = (-↑g : SpecialLinearGroup n R) := diff --git a/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean b/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean index 69bf53aa90f364..0faea6e474555a 100644 --- a/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean +++ b/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean @@ -458,7 +458,7 @@ theorem add_apply (Q Q' : QuadraticMap R M N) (x : M) : (Q + Q') x = Q x + Q' x rfl instance : AddCommMonoid (QuadraticMap R M N) := - DFunLike.coe_injective.addCommMonoid _ coeFn_zero coeFn_add fun _ _ => coeFn_smul _ _ + fast_instance% DFunLike.coe_injective.addCommMonoid _ coeFn_zero coeFn_add fun _ _ => coeFn_smul _ _ /-- `@CoeFn (QuadraticMap R M)` as an `AddMonoidHom`. @@ -542,7 +542,7 @@ theorem sub_apply (Q Q' : QuadraticMap R M N) (x : M) : (Q - Q') x = Q x - Q' x rfl instance : AddCommGroup (QuadraticMap R M N) := - DFunLike.coe_injective.addCommGroup _ coeFn_zero coeFn_add coeFn_neg coeFn_sub + fast_instance% DFunLike.coe_injective.addCommGroup _ coeFn_zero coeFn_add coeFn_neg coeFn_sub (fun _ _ => coeFn_smul _ _) fun _ _ => coeFn_smul _ _ end RingOperators diff --git a/Mathlib/Logic/Embedding/Basic.lean b/Mathlib/Logic/Embedding/Basic.lean index 766bf51361a8fa..34f0092fa66fd2 100644 --- a/Mathlib/Logic/Embedding/Basic.lean +++ b/Mathlib/Logic/Embedding/Basic.lean @@ -10,6 +10,7 @@ public import Mathlib.Data.Prod.Basic public import Mathlib.Data.Prod.PProd public import Mathlib.Data.Sum.Basic public import Mathlib.Logic.Equiv.Basic +public import Mathlib.Tactic.FastInstance /-! # Injective functions @@ -81,7 +82,7 @@ theorem toEmbedding_injective : Function.Injective (Equiv.toEmbedding : (α ≃ fun _ _ h ↦ by rwa [DFunLike.ext'_iff] at h ⊢ instance coeEmbedding : Coe (α ≃ β) (α ↪ β) := - ⟨Equiv.toEmbedding⟩ + fast_instance% ⟨Equiv.toEmbedding⟩ end Equiv diff --git a/Mathlib/Logic/Encodable/Basic.lean b/Mathlib/Logic/Encodable/Basic.lean index 33da624467b19e..3dcc179b0e2617 100644 --- a/Mathlib/Logic/Encodable/Basic.lean +++ b/Mathlib/Logic/Encodable/Basic.lean @@ -264,7 +264,7 @@ theorem decode_sum_val (n : ℕ) : (decode n : Option (α ⊕ β)) = decodeSum n end Sum instance _root_.Bool.encodable : Encodable Bool := - ofEquiv (Unit ⊕ Unit) Equiv.boolEquivPUnitSumPUnit + fast_instance% ofEquiv (Unit ⊕ Unit) Equiv.boolEquivPUnitSumPUnit @[simp] theorem encode_true : encode true = 1 := @@ -294,7 +294,7 @@ theorem decode_ge_two (n) (h : 2 ≤ n) : (decode n : Option Bool) = none := by simp only [decodeSum, div2_val]; cases bodd n <;> simp [e] noncomputable instance _root_.Prop.encodable : Encodable Prop := - ofEquiv Bool Equiv.propEquivBool + fast_instance% ofEquiv Bool Equiv.propEquivBool section Sigma @@ -373,18 +373,18 @@ instance _root_.Fin.encodable (n) : Encodable (Fin n) := ofEquiv _ Fin.equivSubtype instance _root_.Int.encodable : Encodable ℤ := - ofEquiv _ Equiv.intEquivNat + fast_instance% ofEquiv _ Equiv.intEquivNat instance _root_.PNat.encodable : Encodable ℕ+ := - ofEquiv _ Equiv.pnatEquivNat + fast_instance% ofEquiv _ Equiv.pnatEquivNat /-- The lift of an encodable type is encodable -/ instance _root_.ULift.encodable [Encodable α] : Encodable (ULift α) := - ofEquiv _ Equiv.ulift + fast_instance% ofEquiv _ Equiv.ulift /-- The lift of an encodable type is encodable. -/ instance _root_.PLift.encodable [Encodable α] : Encodable (PLift α) := - ofEquiv _ Equiv.plift + fast_instance% ofEquiv _ Equiv.plift /-- If `β` is encodable and there is an injection `f : α → β`, then `α` is encodable as well. -/ @[implicit_reducible] diff --git a/Mathlib/Logic/Encodable/Pi.lean b/Mathlib/Logic/Encodable/Pi.lean index 37545ebd38539f..7923ccc0bf3294 100644 --- a/Mathlib/Logic/Encodable/Pi.lean +++ b/Mathlib/Logic/Encodable/Pi.lean @@ -38,10 +38,10 @@ instance List.Vector.countable [Countable α] {n} : Countable (List.Vector α n) /-- If `α` is encodable, then so is `Fin n → α`. -/ instance finArrow [Encodable α] {n} : Encodable (Fin n → α) := - ofEquiv _ (Equiv.vectorEquivFin _ _).symm + fast_instance% ofEquiv _ (Equiv.vectorEquivFin _ _).symm instance finPi (n) (π : Fin n → Type*) [∀ i, Encodable (π i)] : Encodable (∀ i, π i) := - ofEquiv _ (Equiv.piEquivSubtypeSigma (Fin n) π) + fast_instance% ofEquiv _ (Equiv.piEquivSubtypeSigma (Fin n) π) -- TODO: Unify with `fintypePi` and find a better name /-- When `α` is finite and `β` is encodable, `α → β` is encodable too. Because the encoding is not @@ -64,6 +64,6 @@ def fintypePi (α : Type*) (π : α → Type*) [DecidableEq α] [Fintype α] [ /-- If `α` and `β` are encodable and `α` is a fintype, then `α → β` is encodable as well. -/ instance fintypeArrowOfEncodable {α β : Type*} [Encodable α] [Fintype α] [Encodable β] : Encodable (α → β) := - ofEquiv (Fin (Fintype.card α) → β) <| Equiv.arrowCongr fintypeEquivFin (Equiv.refl _) + fast_instance% ofEquiv (Fin (Fintype.card α) → β) <| Equiv.arrowCongr fintypeEquivFin (Equiv.refl _) end Encodable diff --git a/Mathlib/Logic/Equiv/Array.lean b/Mathlib/Logic/Equiv/Array.lean index 48346267381509..1d56d68f7503b2 100644 --- a/Mathlib/Logic/Equiv/Array.lean +++ b/Mathlib/Logic/Equiv/Array.lean @@ -48,7 +48,7 @@ instance for `array` was) /-- If `α` is encodable, then so is `Array α`. -/ instance Array.encodable {α} [Encodable α] : Encodable (Array α) := - Encodable.ofEquiv _ (Equiv.arrayEquivList _) + fast_instance% Encodable.ofEquiv _ (Equiv.arrayEquivList _) /-- If `α` is countable, then so is `Array α`. -/ instance Array.countable {α} [Countable α] : Countable (Array α) := diff --git a/Mathlib/Logic/Equiv/Defs.lean b/Mathlib/Logic/Equiv/Defs.lean index fccce9f90c4a52..8e4846718fd4b6 100644 --- a/Mathlib/Logic/Equiv/Defs.lean +++ b/Mathlib/Logic/Equiv/Defs.lean @@ -13,6 +13,7 @@ public import Mathlib.Tactic.Simps.Basic public import Mathlib.Tactic.Substs import Mathlib.Tactic.Attr.Register +public import Mathlib.Tactic.FastInstance /-! # Equivalence between types @@ -140,7 +141,7 @@ protected theorem Perm.congr_fun {f g : Equiv.Perm α} (h : f = g) (x : α) : f /-- Any type is equivalent to itself. -/ @[refl] protected def refl (α : Sort*) : α ≃ α := ⟨id, id, fun _ => rfl, fun _ => rfl⟩ -instance inhabited' : Inhabited (α ≃ α) := ⟨Equiv.refl α⟩ +instance inhabited' : Inhabited (α ≃ α) := fast_instance% ⟨Equiv.refl α⟩ /-- Inverse of an equivalence `e : α ≃ β`. -/ @[symm] @@ -199,7 +200,7 @@ instance equiv_subsingleton_dom [Subsingleton α] : Subsingleton (α ≃ β) := ⟨fun f _ => Equiv.ext fun _ => @Subsingleton.elim _ (Equiv.subsingleton.symm f) _ _⟩ instance permUnique [Subsingleton α] : Unique (Perm α) := - uniqueOfSubsingleton (Equiv.refl α) + fast_instance% uniqueOfSubsingleton (Equiv.refl α) theorem Perm.subsingleton_eq_refl [Subsingleton α] (e : Perm α) : e = Equiv.refl α := Subsingleton.elim _ _ diff --git a/Mathlib/Logic/Equiv/PartialEquiv.lean b/Mathlib/Logic/Equiv/PartialEquiv.lean index 579205b85614bd..44f2464bc65c87 100644 --- a/Mathlib/Logic/Equiv/PartialEquiv.lean +++ b/Mathlib/Logic/Equiv/PartialEquiv.lean @@ -246,7 +246,7 @@ def _root_.Equiv.toPartialEquiv (e : α ≃ β) : PartialEquiv α β := e.toPartialEquivOfImageEq univ univ <| by rw [image_univ, e.surjective.range_eq] instance inhabitedOfEmpty [IsEmpty α] [IsEmpty β] : Inhabited (PartialEquiv α β) := - ⟨((Equiv.equivEmpty α).trans (Equiv.equivEmpty β).symm).toPartialEquiv⟩ + fast_instance% ⟨((Equiv.equivEmpty α).trans (Equiv.equivEmpty β).symm).toPartialEquiv⟩ /-- Create a copy of a `PartialEquiv` providing better definitional equalities. -/ @[simps -fullyApplied] diff --git a/Mathlib/MeasureTheory/Function/AEEqFun.lean b/Mathlib/MeasureTheory/Function/AEEqFun.lean index 506c28877e204b..bc076262e7832f 100644 --- a/Mathlib/MeasureTheory/Function/AEEqFun.lean +++ b/Mathlib/MeasureTheory/Function/AEEqFun.lean @@ -549,7 +549,7 @@ theorem liftRel_iff_coeFn {r : β → γ → Prop} {f : α →ₘ[μ] β} {g : section Order instance instPreorder [Preorder β] : Preorder (α →ₘ[μ] β) := - Preorder.lift toGerm + fast_instance% Preorder.lift toGerm @[simp] theorem mk_le_mk [Preorder β] {f g : α → β} (hf hg) : (mk f hf : α →ₘ[μ] β) ≤ mk g hg ↔ f ≤ᵐ[μ] g := @@ -560,7 +560,7 @@ theorem coeFn_le [Preorder β] {f g : α →ₘ[μ] β} : (f : α → β) ≤ᵐ liftRel_iff_coeFn.symm instance instPartialOrder [PartialOrder β] : PartialOrder (α →ₘ[μ] β) := - PartialOrder.lift toGerm toGerm_injective + fast_instance% PartialOrder.lift toGerm toGerm_injective section Lattice diff --git a/Mathlib/MeasureTheory/Function/SimpleFunc.lean b/Mathlib/MeasureTheory/Function/SimpleFunc.lean index b77aae45ac6ad5..9e94bc5c965330 100644 --- a/Mathlib/MeasureTheory/Function/SimpleFunc.lean +++ b/Mathlib/MeasureTheory/Function/SimpleFunc.lean @@ -514,7 +514,7 @@ instance instAddCommMonoid [AddCommMonoid β] : AddCommMonoid (α →ₛ β) := coe_injective coe_zero coe_add fun _ _ => coe_smul _ _ instance instAddGroup [AddGroup β] : AddGroup (α →ₛ β) := - Function.Injective.addGroup (fun f => show α → β from f) coe_injective coe_zero coe_add coe_neg + fast_instance% Function.Injective.addGroup (fun f => show α → β from f) coe_injective coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _ instance instAddCommGroup [AddCommGroup β] : AddCommGroup (α →ₛ β) := @@ -663,7 +663,7 @@ end Star section Preorder variable [Preorder β] {s : Set α} {f f₁ f₂ g g₁ g₂ : α →ₛ β} {hs : MeasurableSet s} -instance instPreorder : Preorder (α →ₛ β) := Preorder.lift (⇑) +instance instPreorder : Preorder (α →ₛ β) := fast_instance% Preorder.lift (⇑) @[simp, norm_cast, gcongr] lemma coe_le_coe : ⇑f ≤ g ↔ f ≤ g := .rfl @[simp, norm_cast, gcongr] lemma coe_lt_coe : ⇑f < g ↔ f < g := .rfl diff --git a/Mathlib/MeasureTheory/MeasurableSpace/Constructions.lean b/Mathlib/MeasureTheory/MeasurableSpace/Constructions.lean index dc0b5f1b5f7f16..85006df62c2737 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/Constructions.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/Constructions.lean @@ -133,7 +133,7 @@ instance Quot.instMeasurableSpace {α} {r : α → α → Prop} [m : MeasurableS instance Quotient.instMeasurableSpace {α} {s : Setoid α} [m : MeasurableSpace α] : MeasurableSpace (Quotient s) := - m.map Quotient.mk'' + fast_instance% m.map Quotient.mk'' @[to_additive] instance QuotientGroup.measurableSpace {G} [Group G] [MeasurableSpace G] (S : Subgroup G) : diff --git a/Mathlib/MeasureTheory/MeasurableSpace/MeasurablyGenerated.lean b/Mathlib/MeasureTheory/MeasurableSpace/MeasurablyGenerated.lean index 8421c40c186d3f..1eb3da1f7992b7 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/MeasurablyGenerated.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/MeasurablyGenerated.lean @@ -283,7 +283,7 @@ theorem coe_top : ↑(⊤ : Subtype (MeasurableSet : Set α → Prop)) = (⊤ : noncomputable instance Subtype.instBooleanAlgebra : BooleanAlgebra (Subtype (MeasurableSet : Set α → Prop)) := - Subtype.coe_injective.booleanAlgebra _ .rfl .rfl coe_union coe_inter coe_top coe_bot coe_compl + fast_instance% Subtype.coe_injective.booleanAlgebra _ .rfl .rfl coe_union coe_inter coe_top coe_bot coe_compl coe_sdiff coe_himp @[measurability] diff --git a/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean b/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean index d754a8f67e6cdb..cd3e4c472f3a64 100644 --- a/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean +++ b/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean @@ -275,7 +275,7 @@ theorem toMeasure_sum {ι : Type*} {s : Finset ι} {ν : ι → FiniteMeasure Ω map_sum toMeasureAddMonoidHom _ _ instance {Ω : Type*} [MeasurableSpace Ω] : Module ℝ≥0 (FiniteMeasure Ω) := - Function.Injective.module _ toMeasureAddMonoidHom toMeasure_injective toMeasure_smul + fast_instance% Function.Injective.module _ toMeasureAddMonoidHom toMeasure_injective toMeasure_smul @[simp] theorem smul_apply [IsScalarTower R ℝ≥0 ℝ≥0] (c : R) (μ : FiniteMeasure Ω) (s : Set Ω) : @@ -504,7 +504,7 @@ theorem toWeakDualBCNN_apply (μ : FiniteMeasure Ω) (f : Ω →ᵇ ℝ≥0) : from the weak-\* topology on `WeakDual ℝ≥0 (Ω →ᵇ ℝ≥0)` via the function `MeasureTheory.FiniteMeasure.toWeakDualBCNN`. -/ instance instTopologicalSpace : TopologicalSpace (FiniteMeasure Ω) := - TopologicalSpace.induced toWeakDualBCNN inferInstance + fast_instance% TopologicalSpace.induced toWeakDualBCNN inferInstance theorem toWeakDualBCNN_continuous : Continuous (@toWeakDualBCNN Ω _ _ _) := continuous_induced_dom diff --git a/Mathlib/MeasureTheory/Measure/ProbabilityMeasure.lean b/Mathlib/MeasureTheory/Measure/ProbabilityMeasure.lean index 89b72124f705da..1f9a41fabd5af7 100644 --- a/Mathlib/MeasureTheory/Measure/ProbabilityMeasure.lean +++ b/Mathlib/MeasureTheory/Measure/ProbabilityMeasure.lean @@ -287,7 +287,7 @@ theorem testAgainstNN_lipschitz (μ : ProbabilityMeasure Ω) : (induced) from the topology of weak convergence of finite measures via the inclusion `MeasureTheory.ProbabilityMeasure.toFiniteMeasure`. -/ instance : TopologicalSpace (ProbabilityMeasure Ω) := - TopologicalSpace.induced toFiniteMeasure inferInstance + fast_instance% TopologicalSpace.induced toFiniteMeasure inferInstance theorem toFiniteMeasure_continuous : Continuous (toFiniteMeasure : ProbabilityMeasure Ω → FiniteMeasure Ω) := diff --git a/Mathlib/MeasureTheory/VectorMeasure/Basic.lean b/Mathlib/MeasureTheory/VectorMeasure/Basic.lean index 4cf20ddf8f1627..5cf107fa45a90c 100644 --- a/Mathlib/MeasureTheory/VectorMeasure/Basic.lean +++ b/Mathlib/MeasureTheory/VectorMeasure/Basic.lean @@ -305,7 +305,7 @@ theorem coe_add (v w : VectorMeasure α M) : ⇑(v + w) = v + w := rfl theorem add_apply (v w : VectorMeasure α M) (i : Set α) : (v + w) i = v i + w i := rfl instance instAddCommMonoid : AddCommMonoid (VectorMeasure α M) := - Function.Injective.addCommMonoid _ coe_injective coe_zero coe_add fun _ _ => coe_smul _ _ + fast_instance% Function.Injective.addCommMonoid _ coe_injective coe_zero coe_add fun _ _ => coe_smul _ _ /-- `(⇑)` is an `AddMonoidHom`. -/ @[simps] @@ -351,7 +351,7 @@ theorem coe_sub (v w : VectorMeasure α M) : ⇑(v - w) = v - w := rfl theorem sub_apply (v w : VectorMeasure α M) (i : Set α) : (v - w) i = v i - w i := rfl instance instAddCommGroup : AddCommGroup (VectorMeasure α M) := - Function.Injective.addCommGroup _ coe_injective coe_zero coe_add coe_neg coe_sub + fast_instance% Function.Injective.addCommGroup _ coe_injective coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _ end AddCommGroup @@ -362,7 +362,7 @@ variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M] variable {R : Type*} [Semiring R] [DistribMulAction R M] [ContinuousConstSMul R M] instance instDistribMulAction [ContinuousAdd M] : DistribMulAction R (VectorMeasure α M) := - Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective coe_smul + fast_instance% Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective coe_smul end DistribMulAction @@ -372,7 +372,7 @@ variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M] variable {R : Type*} [Semiring R] [Module R M] [ContinuousConstSMul R M] instance instModule [ContinuousAdd M] : Module R (VectorMeasure α M) := - Function.Injective.module R coeFnAddMonoidHom coe_injective coe_smul + fast_instance% Function.Injective.module R coeFnAddMonoidHom coe_injective coe_smul end Module diff --git a/Mathlib/NumberTheory/ModularForms/Basic.lean b/Mathlib/NumberTheory/ModularForms/Basic.lean index c1ab072b3417d7..9b16e6f51e602d 100644 --- a/Mathlib/NumberTheory/ModularForms/Basic.lean +++ b/Mathlib/NumberTheory/ModularForms/Basic.lean @@ -312,7 +312,7 @@ theorem sub_apply (f g : ModularForm Γ k) (z : ℍ) : (f - g) z = f z - g z := rfl instance : AddCommGroup (ModularForm Γ k) := - DFunLike.coe_injective.addCommGroup _ rfl coe_add coe_neg coe_sub coe_smul coe_smul + fast_instance% DFunLike.coe_injective.addCommGroup _ rfl coe_add coe_neg coe_sub coe_smul coe_smul /-- Additive coercion from `ModularForm` to `ℍ → ℂ`. -/ @[simps] @@ -322,10 +322,10 @@ def coeHom : ModularForm Γ k →+ ℍ → ℂ where map_add' _ _ := rfl instance : Module ℝ (ModularForm Γ k) := - Function.Injective.module ℝ coeHom DFunLike.coe_injective fun _ _ => rfl + fast_instance% Function.Injective.module ℝ coeHom DFunLike.coe_injective fun _ _ => rfl instance [Γ.HasDetOne] : Module ℂ (ModularForm Γ k) := - Function.Injective.module ℂ coeHom DFunLike.coe_injective fun _ _ => rfl + fast_instance% Function.Injective.module ℂ coeHom DFunLike.coe_injective fun _ _ => rfl instance : Inhabited (ModularForm Γ k) := ⟨0⟩ @@ -506,7 +506,7 @@ theorem sub_apply (f g : CuspForm Γ k) (z : ℍ) : (f - g) z = f z - g z := rfl instance : AddCommGroup (CuspForm Γ k) := - DFunLike.coe_injective.addCommGroup _ rfl coe_add coe_neg coe_sub coe_smul coe_smul + fast_instance% DFunLike.coe_injective.addCommGroup _ rfl coe_add coe_neg coe_sub coe_smul coe_smul /-- Additive coercion from `CuspForm` to `ℍ → ℂ`. -/ @[simps] @@ -516,10 +516,10 @@ def coeHom : CuspForm Γ k →+ ℍ → ℂ where map_add' _ _ := rfl instance : Module ℝ (CuspForm Γ k) := - Function.Injective.module ℝ coeHom DFunLike.coe_injective fun _ _ => rfl + fast_instance% Function.Injective.module ℝ coeHom DFunLike.coe_injective fun _ _ => rfl instance [Γ.HasDetOne] : Module ℂ (CuspForm Γ k) := - Function.Injective.module ℂ coeHom DFunLike.coe_injective fun _ _ => rfl + fast_instance% Function.Injective.module ℂ coeHom DFunLike.coe_injective fun _ _ => rfl instance : Inhabited (CuspForm Γ k) := ⟨0⟩ diff --git a/Mathlib/NumberTheory/ModularForms/SlashInvariantForms.lean b/Mathlib/NumberTheory/ModularForms/SlashInvariantForms.lean index c6928cd5db289d..219284d9ccb866 100644 --- a/Mathlib/NumberTheory/ModularForms/SlashInvariantForms.lean +++ b/Mathlib/NumberTheory/ModularForms/SlashInvariantForms.lean @@ -203,7 +203,7 @@ theorem sub_apply (f g : SlashInvariantForm Γ k) (z : ℍ) : (f - g) z = f z - rfl instance : AddCommGroup (SlashInvariantForm Γ k) := - DFunLike.coe_injective.addCommGroup _ rfl coe_add coe_neg coe_sub coe_smulℝ coe_smulℝ + fast_instance% DFunLike.coe_injective.addCommGroup _ rfl coe_add coe_neg coe_sub coe_smulℝ coe_smulℝ /-- Additive coercion from `SlashInvariantForm` to `ℍ → ℂ`. -/ def coeHom : SlashInvariantForm Γ k →+ ℍ → ℂ where diff --git a/Mathlib/NumberTheory/NumberField/InfinitePlace/Embeddings.lean b/Mathlib/NumberTheory/NumberField/InfinitePlace/Embeddings.lean index 16feaf41197085..330cf2e647f6ef 100644 --- a/Mathlib/NumberTheory/NumberField/InfinitePlace/Embeddings.lean +++ b/Mathlib/NumberTheory/NumberField/InfinitePlace/Embeddings.lean @@ -53,7 +53,7 @@ variable [NumberField K] /-- There are finitely many embeddings of a number field. -/ noncomputable instance : Fintype (K →+* A) := - Fintype.ofEquiv (K →ₐ[ℚ] A) RingHom.equivRatAlgHom.symm + fast_instance% Fintype.ofEquiv (K →ₐ[ℚ] A) RingHom.equivRatAlgHom.symm variable [IsAlgClosed A] diff --git a/Mathlib/Order/BoundedOrder/Basic.lean b/Mathlib/Order/BoundedOrder/Basic.lean index 2d82c7360e5202..cdedd5126e1105 100644 --- a/Mathlib/Order/BoundedOrder/Basic.lean +++ b/Mathlib/Order/BoundedOrder/Basic.lean @@ -9,6 +9,7 @@ public import Mathlib.Order.Max public import Mathlib.Order.ULift public import Mathlib.Tactic.ByCases public import Mathlib.Tactic.Finiteness.Attr +public import Mathlib.Tactic.FastInstance /-! # ⊤ and ⊥, bounded lattices and variants @@ -441,7 +442,7 @@ instance [Top α] : Top (ULift.{v} α) where top := up ⊤ @[to_dual] instance [LE α] [OrderBot α] : OrderBot (ULift.{v} α) := - OrderBot.lift ULift.down (fun _ _ => down_le.mp) down_bot + fast_instance% OrderBot.lift ULift.down (fun _ _ => down_le.mp) down_bot instance [LE α] [BoundedOrder α] : BoundedOrder (ULift.{v} α) where diff --git a/Mathlib/Order/Filter/Germ/Basic.lean b/Mathlib/Order/Filter/Germ/Basic.lean index f9557801ceccda..65ec76cefde8bb 100644 --- a/Mathlib/Order/Filter/Germ/Basic.lean +++ b/Mathlib/Order/Filter/Germ/Basic.lean @@ -98,7 +98,7 @@ namespace Product variable {ε : α → Type*} instance coeTC : CoeTC ((a : _) → ε a) (l.Product ε) := - ⟨@Quotient.mk' _ (productSetoid _ ε)⟩ + fast_instance% ⟨@Quotient.mk' _ (productSetoid _ ε)⟩ instance instInhabited [(a : _) → Inhabited (ε a)] : Inhabited (l.Product ε) := ⟨(↑fun a => (default : ε a) : l.Product ε)⟩ diff --git a/Mathlib/Order/Heyting/Hom.lean b/Mathlib/Order/Heyting/Hom.lean index 480d84b913689e..4c36168fe77e18 100644 --- a/Mathlib/Order/Heyting/Hom.lean +++ b/Mathlib/Order/Heyting/Hom.lean @@ -6,6 +6,7 @@ Authors: Yaël Dillies module public import Mathlib.Order.Hom.BoundedLattice +public import Mathlib.Tactic.FastInstance /-! # Heyting algebra morphisms @@ -299,7 +300,7 @@ instance : Inhabited (HeytingHom α α) := ⟨HeytingHom.id _⟩ instance : PartialOrder (HeytingHom α β) := - PartialOrder.lift _ DFunLike.coe_injective + fast_instance% PartialOrder.lift _ DFunLike.coe_injective /-- Composition of `HeytingHom`s as a `HeytingHom`. -/ def comp (f : HeytingHom β γ) (g : HeytingHom α β) : HeytingHom α γ := @@ -404,7 +405,7 @@ instance : Inhabited (CoheytingHom α α) := ⟨CoheytingHom.id _⟩ instance : PartialOrder (CoheytingHom α β) := - PartialOrder.lift _ DFunLike.coe_injective + fast_instance% PartialOrder.lift _ DFunLike.coe_injective /-- Composition of `CoheytingHom`s as a `CoheytingHom`. -/ def comp (f : CoheytingHom β γ) (g : CoheytingHom α β) : CoheytingHom α γ := @@ -507,7 +508,7 @@ instance : Inhabited (BiheytingHom α α) := ⟨BiheytingHom.id _⟩ instance : PartialOrder (BiheytingHom α β) := - PartialOrder.lift _ DFunLike.coe_injective + fast_instance% PartialOrder.lift _ DFunLike.coe_injective /-- Composition of `BiheytingHom`s as a `BiheytingHom`. -/ def comp (f : BiheytingHom β γ) (g : BiheytingHom α β) : BiheytingHom α γ := diff --git a/Mathlib/Order/Heyting/Regular.lean b/Mathlib/Order/Heyting/Regular.lean index 2e68615886eb1c..b7f4860d9c46b4 100644 --- a/Mathlib/Order/Heyting/Regular.lean +++ b/Mathlib/Order/Heyting/Regular.lean @@ -154,10 +154,10 @@ instance : Inhabited (Regular α) := ⟨⊥⟩ instance : PartialOrder (Regular α) := - PartialOrder.lift _ coe_injective + fast_instance% PartialOrder.lift _ coe_injective instance boundedOrder : BoundedOrder (Regular α) := - BoundedOrder.lift ((↑) : Regular α → α) (fun _ _ => id) coe_top coe_bot + fast_instance% BoundedOrder.lift ((↑) : Regular α → α) (fun _ _ => id) coe_top coe_bot @[simp, norm_cast] theorem coe_le_coe {a b : Regular α} : (a : α) ≤ b ↔ a ≤ b := diff --git a/Mathlib/Order/Hom/Basic.lean b/Mathlib/Order/Hom/Basic.lean index e2b2ed52abb9a1..5d80d7840b9410 100644 --- a/Mathlib/Order/Hom/Basic.lean +++ b/Mathlib/Order/Hom/Basic.lean @@ -9,6 +9,7 @@ public import Mathlib.Order.Disjoint public import Mathlib.Order.RelIso.Basic public import Mathlib.Tactic.Monotonicity.Attr public import Mathlib.Tactic.PPWithUniv +public import Mathlib.Tactic.FastInstance /-! # Order homomorphisms @@ -287,10 +288,10 @@ instance : Inhabited (α →o α) := /-- The preorder structure of `α →o β` is pointwise inequality: `f ≤ g ↔ ∀ a, f a ≤ g a`. -/ instance : Preorder (α →o β) := - @Preorder.lift (α →o β) (α → β) _ DFunLike.coe + fast_instance% @Preorder.lift (α →o β) (α → β) _ DFunLike.coe instance {β : Type*} [PartialOrder β] : PartialOrder (α →o β) := - @PartialOrder.lift (α →o β) (α → β) _ toFun ext + fast_instance% @PartialOrder.lift (α →o β) (α → β) _ toFun ext @[to_dual self] theorem le_def {f g : α →o β} : f ≤ g ↔ ∀ x, f x ≤ g x := diff --git a/Mathlib/Order/Hom/Bounded.lean b/Mathlib/Order/Hom/Bounded.lean index 82a22aeb1a48a6..99309764299d48 100644 --- a/Mathlib/Order/Hom/Bounded.lean +++ b/Mathlib/Order/Hom/Bounded.lean @@ -6,6 +6,7 @@ Authors: Yaël Dillies module public import Mathlib.Order.Hom.Basic +public import Mathlib.Tactic.FastInstance /-! # Bounded order homomorphisms @@ -310,7 +311,7 @@ instance : Min (TopHom α β) := @[to_dual] instance : SemilatticeInf (TopHom α β) := - DFunLike.coe_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl @[to_dual (attr := simp)] theorem coe_inf : ⇑(f ⊓ g) = ⇑f ⊓ ⇑g := @@ -332,7 +333,7 @@ instance : Max (TopHom α β) := @[to_dual] instance : SemilatticeSup (TopHom α β) := - DFunLike.coe_injective.semilatticeSup _ .rfl .rfl fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.semilatticeSup _ .rfl .rfl fun _ _ ↦ rfl @[to_dual (attr := simp)] theorem coe_sup : ⇑(f ⊔ g) = ⇑f ⊔ ⇑g := diff --git a/Mathlib/Order/Hom/BoundedLattice.lean b/Mathlib/Order/Hom/BoundedLattice.lean index 3e7abaa4480e0a..57baff608f9fd9 100644 --- a/Mathlib/Order/Hom/BoundedLattice.lean +++ b/Mathlib/Order/Hom/BoundedLattice.lean @@ -8,6 +8,7 @@ module public import Mathlib.Order.Hom.Bounded public import Mathlib.Order.Hom.Lattice public import Mathlib.Order.SymmDiff +public import Mathlib.Tactic.FastInstance /-! # Bounded lattice homomorphisms @@ -305,7 +306,7 @@ instance : PartialOrder (SupBotHom α β) := @[to_dual] instance : SemilatticeSup (SupBotHom α β) := - DFunLike.coe_injective.semilatticeSup _ .rfl .rfl fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.semilatticeSup _ .rfl .rfl fun _ _ ↦ rfl @[to_dual] instance : OrderBot (SupBotHom α β) where diff --git a/Mathlib/Order/Hom/CompleteLattice.lean b/Mathlib/Order/Hom/CompleteLattice.lean index 6eb8d8de416946..e203dac72181df 100644 --- a/Mathlib/Order/Hom/CompleteLattice.lean +++ b/Mathlib/Order/Hom/CompleteLattice.lean @@ -438,7 +438,7 @@ theorem cancel_left {g : FrameHom β γ} {f₁ f₂ : FrameHom α β} (hg : Inje ⟨fun h => ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩ instance : PartialOrder (FrameHom α β) := - PartialOrder.lift _ DFunLike.coe_injective + fast_instance% PartialOrder.lift _ DFunLike.coe_injective end FrameHom diff --git a/Mathlib/Order/Hom/Lattice.lean b/Mathlib/Order/Hom/Lattice.lean index 34ab68410bd210..d186987becf5b4 100644 --- a/Mathlib/Order/Hom/Lattice.lean +++ b/Mathlib/Order/Hom/Lattice.lean @@ -6,6 +6,7 @@ Authors: Yaël Dillies module public import Mathlib.Order.Hom.Basic +public import Mathlib.Tactic.FastInstance /-! # Unbounded lattice homomorphisms @@ -287,7 +288,7 @@ instance : PartialOrder (SupHom α β) := @[to_dual] instance : SemilatticeSup (SupHom α β) := - DFunLike.coe_injective.semilatticeSup _ .rfl .rfl fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.semilatticeSup _ .rfl .rfl fun _ _ ↦ rfl @[to_dual] instance [Bot β] : Bot (SupHom α β) := @@ -299,15 +300,15 @@ instance [Top β] : Top (SupHom α β) := @[to_dual] instance [OrderBot β] : OrderBot (SupHom α β) := - OrderBot.lift ((↑) : _ → α → β) (fun _ _ => id) rfl + fast_instance% OrderBot.lift ((↑) : _ → α → β) (fun _ _ => id) rfl @[to_dual] instance [OrderTop β] : OrderTop (SupHom α β) := - OrderTop.lift ((↑) : _ → α → β) (fun _ _ => id) rfl + fast_instance% OrderTop.lift ((↑) : _ → α → β) (fun _ _ => id) rfl @[to_dual] instance [BoundedOrder β] : BoundedOrder (SupHom α β) := - BoundedOrder.lift ((↑) : _ → α → β) (fun _ _ => id) rfl rfl + fast_instance% BoundedOrder.lift ((↑) : _ → α → β) (fun _ _ => id) rfl rfl @[to_dual (attr := simp)] theorem coe_sup (f g : SupHom α β) : ⇑(f ⊔ g) = ⇑f ⊔ ⇑g := diff --git a/Mathlib/Order/UpperLower/CompleteLattice.lean b/Mathlib/Order/UpperLower/CompleteLattice.lean index 7f72a824a287ef..ddb78d09bf25ef 100644 --- a/Mathlib/Order/UpperLower/CompleteLattice.lean +++ b/Mathlib/Order/UpperLower/CompleteLattice.lean @@ -89,7 +89,7 @@ instance : InfSet (UpperSet α) := ⟨fun S => ⟨⋃ s ∈ S, ↑s, isUpperSet_iUnion₂ fun s _ => s.upper⟩⟩ instance : PartialOrder (UpperSet α) := - PartialOrder.lift _ (toDual.injective.comp SetLike.coe_injective) + fast_instance% PartialOrder.lift _ (toDual.injective.comp SetLike.coe_injective) instance completeLattice : CompleteLattice (UpperSet α) := (toDual.injective.comp SetLike.coe_injective).completeLattice _ @@ -102,16 +102,16 @@ instance completelyDistribLattice : CompletelyDistribLattice (UpperSet α) := @[to_dual existing] instance _root_.LowerSet.instPartialOrder : PartialOrder (LowerSet α) := - PartialOrder.lift _ SetLike.coe_injective + fast_instance% PartialOrder.lift _ SetLike.coe_injective @[to_dual existing] instance _root_.LowerSet.completeLattice : CompleteLattice (LowerSet α) := - SetLike.coe_injective.completeLattice _ + fast_instance% SetLike.coe_injective.completeLattice _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) rfl rfl @[to_dual existing] instance _root_.LowerSet.completelyDistribLattice : CompletelyDistribLattice (LowerSet α) := - .ofMinimalAxioms <| SetLike.coe_injective.completelyDistribLatticeMinimalAxioms .of _ + fast_instance% .ofMinimalAxioms <| SetLike.coe_injective.completelyDistribLatticeMinimalAxioms .of _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) rfl rfl @[to_dual] diff --git a/Mathlib/Probability/Kernel/Defs.lean b/Mathlib/Probability/Kernel/Defs.lean index 42574a7c8e399d..df421628ee40ca 100644 --- a/Mathlib/Probability/Kernel/Defs.lean +++ b/Mathlib/Probability/Kernel/Defs.lean @@ -100,7 +100,7 @@ noncomputable instance instSMulNat : SMul ℕ (Kernel α β) where @[simp] lemma nsmul_apply (n : ℕ) (κ : Kernel α β) (a : α) : (n • κ) a = n • κ a := rfl noncomputable instance instAddCommMonoid : AddCommMonoid (Kernel α β) := - DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add (by intros; rfl) + fast_instance% DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add (by intros; rfl) instance instPartialOrder : PartialOrder (Kernel α β) := .lift _ DFunLike.coe_injective diff --git a/Mathlib/RingTheory/AdicCompletion/Algebra.lean b/Mathlib/RingTheory/AdicCompletion/Algebra.lean index 1e0a44aef7ebf6..5d3f661f420146 100644 --- a/Mathlib/RingTheory/AdicCompletion/Algebra.lean +++ b/Mathlib/RingTheory/AdicCompletion/Algebra.lean @@ -284,7 +284,7 @@ theorem val_smul_eq_evalₐ_smul (n : ℕ) (r : AdicCompletion I R) induction r using induction_on; rfl instance : Module (R ⧸ (I • ⊤ : Ideal R)) (M ⧸ (I • ⊤ : Submodule R M)) := - Function.Surjective.moduleLeft (Ideal.Quotient.mk (I • ⊤ : Ideal R)) + fast_instance% Function.Surjective.moduleLeft (Ideal.Quotient.mk (I • ⊤ : Ideal R)) Ideal.Quotient.mk_surjective (fun _ _ ↦ rfl) instance : IsScalarTower R (R ⧸ (I • ⊤ : Ideal R)) (M ⧸ (I • ⊤ : Submodule R M)) where diff --git a/Mathlib/RingTheory/DedekindDomain/FiniteAdeleRing.lean b/Mathlib/RingTheory/DedekindDomain/FiniteAdeleRing.lean index 04f4e70ad2d51b..ef829073cd27f5 100644 --- a/Mathlib/RingTheory/DedekindDomain/FiniteAdeleRing.lean +++ b/Mathlib/RingTheory/DedekindDomain/FiniteAdeleRing.lean @@ -127,7 +127,7 @@ instance : Algebra K (FiniteAdeleRing R K) := (FiniteAdeleRing.algebraMap R K).t theorem algebraMap_apply (k : K) (v : HeightOneSpectrum R) : algebraMap K (FiniteAdeleRing R K) k v = k := rfl -instance : Algebra R (FiniteAdeleRing R K) := Algebra.compHom _ (algebraMap R K) +instance : Algebra R (FiniteAdeleRing R K) := fast_instance% Algebra.compHom _ (algebraMap R K) instance : IsScalarTower R K (FiniteAdeleRing R K) := IsScalarTower.of_algebraMap_eq' rfl diff --git a/Mathlib/RingTheory/Derivation/Basic.lean b/Mathlib/RingTheory/Derivation/Basic.lean index 4473baba2d14ad..d86cae7dc5d14c 100644 --- a/Mathlib/RingTheory/Derivation/Basic.lean +++ b/Mathlib/RingTheory/Derivation/Basic.lean @@ -239,7 +239,7 @@ def coeFnAddMonoidHom : Derivation R A M →+ A → M where lemma coeFnAddMonoidHom_apply (D : Derivation R A M) : coeFnAddMonoidHom D = D := rfl instance : DistribMulAction S (Derivation R A M) := - Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective coe_smul + fast_instance% Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective coe_smul instance [DistribMulAction Sᵐᵒᵖ M] [IsCentralScalar S M] : IsCentralScalar S (Derivation R A M) where @@ -255,7 +255,7 @@ end Scalar instance instModule {S : Type*} [Semiring S] [Module S M] [SMulCommClass R S M] [SMulCommClass S A M] : Module S (Derivation R A M) := - Function.Injective.module S coeFnAddMonoidHom coe_injective coe_smul + fast_instance% Function.Injective.module S coeFnAddMonoidHom coe_injective coe_smul section PushForward diff --git a/Mathlib/RingTheory/Extension/Basic.lean b/Mathlib/RingTheory/Extension/Basic.lean index eefde687aba817..0a647c3e2bc56b 100644 --- a/Mathlib/RingTheory/Extension/Basic.lean +++ b/Mathlib/RingTheory/Extension/Basic.lean @@ -67,7 +67,7 @@ attribute [simp] algebraMap_σ -- We want to make sure `R₀` acts compatibly on `R` and `S` to avoid nonsensical instances @[nolint unusedArguments] noncomputable instance {R₀} [CommRing R₀] [Algebra R₀ R] [Algebra R₀ S] [IsScalarTower R₀ R S] : - Algebra R₀ P.Ring := Algebra.compHom P.Ring (algebraMap R₀ R) + Algebra R₀ P.Ring := fast_instance% Algebra.compHom P.Ring (algebraMap R₀ R) instance {R₀} [CommRing R₀] [Algebra R₀ R] [Algebra R₀ S] [IsScalarTower R₀ R S] : IsScalarTower R₀ R P.Ring := IsScalarTower.of_algebraMap_eq' rfl @@ -377,7 +377,7 @@ instance Cotangent.module : Module S P.Cotangent where noncomputable instance {R₀} [CommRing R₀] [Algebra R₀ S] : Module R₀ P.Cotangent := - Module.compHom P.Cotangent (algebraMap R₀ S) + fast_instance% Module.compHom P.Cotangent (algebraMap R₀ S) instance {R₁ R₂} [CommRing R₁] [CommRing R₂] [Algebra R₁ S] [Algebra R₂ S] [Algebra R₁ R₂] [IsScalarTower R₁ R₂ S] : diff --git a/Mathlib/RingTheory/FractionalIdeal/Basic.lean b/Mathlib/RingTheory/FractionalIdeal/Basic.lean index 7da7550e129b2f..0d2af43de4d351 100644 --- a/Mathlib/RingTheory/FractionalIdeal/Basic.lean +++ b/Mathlib/RingTheory/FractionalIdeal/Basic.lean @@ -471,7 +471,7 @@ theorem coe_sup (I J : FractionalIdeal S P) : ↑(I ⊔ J) = (I ⊔ J : Submodul rfl instance lattice : Lattice (FractionalIdeal S P) := - Function.Injective.lattice _ Subtype.coe_injective .rfl .rfl coe_sup coe_inf + fast_instance% Function.Injective.lattice _ Subtype.coe_injective .rfl .rfl coe_sup coe_inf end Lattice @@ -606,7 +606,7 @@ theorem coe_natCast (n : ℕ) : ((n : FractionalIdeal S P) : Submodule R P) = n by induction n <;> simp [*, Nat.unaryCast] instance commSemiring : CommSemiring (FractionalIdeal S P) := - Function.Injective.commSemiring _ Subtype.coe_injective coe_zero coe_one coe_add coe_mul + fast_instance% Function.Injective.commSemiring _ Subtype.coe_injective coe_zero coe_one coe_add coe_mul (fun _ _ => coe_nsmul _ _) coe_pow coe_natCast instance : CanonicallyOrderedAdd (FractionalIdeal S P) where diff --git a/Mathlib/RingTheory/HahnSeries/Lex.lean b/Mathlib/RingTheory/HahnSeries/Lex.lean index 842ad48b5145fd..61b83c07ddba07 100644 --- a/Mathlib/RingTheory/HahnSeries/Lex.lean +++ b/Mathlib/RingTheory/HahnSeries/Lex.lean @@ -36,7 +36,7 @@ section PartialOrder variable [Zero R] [PartialOrder R] instance : PartialOrder (Lex R⟦Γ⟧) := - PartialOrder.lift (toLex <| ofLex · |>.coeff) fun x y ↦ by simp + fast_instance% PartialOrder.lift (toLex <| ofLex · |>.coeff) fun x y ↦ by simp theorem lt_iff (a b : Lex R⟦Γ⟧) : a < b ↔ ∃ (i : Γ), (∀ (j : Γ), j < i → (ofLex a).coeff j = (ofLex b).coeff j) diff --git a/Mathlib/RingTheory/Ideal/Quotient/Defs.lean b/Mathlib/RingTheory/Ideal/Quotient/Defs.lean index 8d166b22ab4679..c573d3ebfbd674 100644 --- a/Mathlib/RingTheory/Ideal/Quotient/Defs.lean +++ b/Mathlib/RingTheory/Ideal/Quotient/Defs.lean @@ -50,7 +50,7 @@ namespace Quotient variable {I} {x y : R} instance one (I : Ideal R) : One (R ⧸ I) := - ⟨Submodule.Quotient.mk 1⟩ + fast_instance% ⟨Submodule.Quotient.mk 1⟩ set_option backward.isDefEq.respectTransparency false in /-- On `Ideal`s, `Submodule.quotientRel` is a ring congruence. -/ @@ -86,7 +86,7 @@ def mk : R →+* R ⧸ I where map_add' _ _ := rfl instance : Coe R (R ⧸ I) := - ⟨Ideal.Quotient.mk I⟩ + fast_instance% ⟨Ideal.Quotient.mk I⟩ /-- Two `RingHom`s from the quotient by an ideal are equal if their compositions with `Ideal.Quotient.mk'` are equal. diff --git a/Mathlib/RingTheory/IntegralClosure/IntegralRestrict.lean b/Mathlib/RingTheory/IntegralClosure/IntegralRestrict.lean index 4632e56e931129..b49cbd957a3ced 100644 --- a/Mathlib/RingTheory/IntegralClosure/IntegralRestrict.lean +++ b/Mathlib/RingTheory/IntegralClosure/IntegralRestrict.lean @@ -216,7 +216,7 @@ attribute [local instance] FractionRing.liftAlgebra FractionRing.isScalarTower_l noncomputable instance (priority := 900) [IsDomain A] [IsDomain B] [IsIntegrallyClosed B] [Module.Finite A B] [IsTorsionFree A B] : Fintype (B ≃ₐ[A] B) := - haveI : IsIntegralClosure B A (FractionRing B) := + fast_instance% haveI : IsIntegralClosure B A (FractionRing B) := IsIntegralClosure.of_isIntegrallyClosed _ _ _ -- TODO: How is this even supposed to fire? `R` and `S` cannot be inferred. haveI : Algebra.IsAlgebraic (FractionRing A) (FractionRing B) := diff --git a/Mathlib/RingTheory/LocalRing/ResidueField/Basic.lean b/Mathlib/RingTheory/LocalRing/ResidueField/Basic.lean index 92801ec958611a..37e86fb91dfcfe 100644 --- a/Mathlib/RingTheory/LocalRing/ResidueField/Basic.lean +++ b/Mathlib/RingTheory/LocalRing/ResidueField/Basic.lean @@ -164,7 +164,7 @@ variable (G : Type*) [Group G] [MulSemiringAction G R] /-- If `G` acts on `R` as a `MulSemiringAction`, then it also acts on `IsLocalRing.ResidueField R`. -/ noncomputable instance : MulSemiringAction G (IsLocalRing.ResidueField R) := - MulSemiringAction.compHom _ <| mapAut.comp (MulSemiringAction.toRingAut G R) + fast_instance% MulSemiringAction.compHom _ <| mapAut.comp (MulSemiringAction.toRingAut G R) @[simp] theorem residue_smul (g : G) (r : R) : residue R (g • r) = g • residue R r := diff --git a/Mathlib/RingTheory/Spectrum/Maximal/Topology.lean b/Mathlib/RingTheory/Spectrum/Maximal/Topology.lean index 824b15d19cacbb..f0463178aff988 100644 --- a/Mathlib/RingTheory/Spectrum/Maximal/Topology.lean +++ b/Mathlib/RingTheory/Spectrum/Maximal/Topology.lean @@ -41,7 +41,7 @@ theorem toPrimeSpectrum_range : /-- The Zariski topology on the maximal spectrum of a commutative ring is defined as the subspace topology induced by the natural inclusion into the prime spectrum. -/ instance zariskiTopology : TopologicalSpace <| MaximalSpectrum R := - PrimeSpectrum.zariskiTopology.induced toPrimeSpectrum + fast_instance% PrimeSpectrum.zariskiTopology.induced toPrimeSpectrum instance : T1Space <| MaximalSpectrum R := ⟨fun x => isClosed_induced_iff.mpr diff --git a/Mathlib/RingTheory/Spectrum/Prime/Defs.lean b/Mathlib/RingTheory/Spectrum/Prime/Defs.lean index a8fca85db59474..acfa46192279e1 100644 --- a/Mathlib/RingTheory/Spectrum/Prime/Defs.lean +++ b/Mathlib/RingTheory/Spectrum/Prime/Defs.lean @@ -53,7 +53,7 @@ instance : Coe (PrimeSpectrum R) (Ideal R) where coe P := P.asIdeal instance : PartialOrder (PrimeSpectrum R) := - PartialOrder.lift asIdeal (@PrimeSpectrum.ext _ _) + fast_instance% PartialOrder.lift asIdeal (@PrimeSpectrum.ext _ _) @[simp] theorem asIdeal_le_asIdeal (x y : PrimeSpectrum R) : x.asIdeal ≤ y.asIdeal ↔ x ≤ y := diff --git a/Mathlib/RingTheory/Valuation/ValuationRing.lean b/Mathlib/RingTheory/Valuation/ValuationRing.lean index bc71ae1e143939..bbb305559f9401 100644 --- a/Mathlib/RingTheory/Valuation/ValuationRing.lean +++ b/Mathlib/RingTheory/Valuation/ValuationRing.lean @@ -76,7 +76,7 @@ variable (K : Type v) [Field K] [Algebra A K] /-- The value group of the valuation ring `A`. Note: this is actually a group with zero. -/ def ValueGroup : Type v := Quotient (MulAction.orbitRel Aˣ K) -instance : Inhabited (ValueGroup A K) := ⟨Quotient.mk'' 0⟩ +instance : Inhabited (ValueGroup A K) := fast_instance% ⟨Quotient.mk'' 0⟩ instance : LE (ValueGroup A K) := LE.mk fun x y => @@ -92,12 +92,12 @@ instance : LE (ValueGroup A K) := simp_rw [Units.smul_def, ← he, mul_smul] rw [← mul_smul _ _ b, Units.inv_mul, one_smul]) -instance : Zero (ValueGroup A K) := ⟨Quotient.mk'' 0⟩ +instance : Zero (ValueGroup A K) := fast_instance% ⟨Quotient.mk'' 0⟩ -instance : One (ValueGroup A K) := ⟨Quotient.mk'' 1⟩ +instance : One (ValueGroup A K) := fast_instance% ⟨Quotient.mk'' 1⟩ instance : Mul (ValueGroup A K) := - Mul.mk fun x y => + fast_instance% Mul.mk fun x y => Quotient.liftOn₂' x y (fun a b => Quotient.mk'' <| a * b) (by rintro _ _ a b ⟨c, rfl⟩ ⟨d, rfl⟩ @@ -108,7 +108,7 @@ instance : Mul (ValueGroup A K) := ring) instance : Inv (ValueGroup A K) := - Inv.mk fun x => + fast_instance% Inv.mk fun x => Quotient.liftOn' x (fun a => Quotient.mk'' a⁻¹) (by rintro _ a ⟨b, rfl⟩ diff --git a/Mathlib/SetTheory/Cardinal/Defs.lean b/Mathlib/SetTheory/Cardinal/Defs.lean index a169cf2dc00fa0..ef726276637ade 100644 --- a/Mathlib/SetTheory/Cardinal/Defs.lean +++ b/Mathlib/SetTheory/Cardinal/Defs.lean @@ -8,6 +8,7 @@ module public import Mathlib.Data.ULift public import Mathlib.Tactic.PPWithUniv public import Mathlib.Util.Delaborators +public import Mathlib.Tactic.FastInstance /-! # Cardinal Numbers @@ -243,7 +244,7 @@ theorem mk_eq_one (α : Type u) [Subsingleton α] [Nonempty α] : #α = 1 := let ⟨_⟩ := nonempty_unique α; (Equiv.ofUnique α (ULift (Fin 1))).cardinal_eq instance : Add Cardinal.{u} := - ⟨map₂ Sum fun _ _ _ _ => Equiv.sumCongr⟩ + fast_instance% ⟨map₂ Sum fun _ _ _ _ => Equiv.sumCongr⟩ theorem add_def (α β : Type u) : #α + #β = #(α ⊕ β) := rfl @@ -264,7 +265,7 @@ theorem mk_psum (α : Type u) (β : Type v) : #(α ⊕' β) = lift.{v} #α + lif (mk_congr (Equiv.psumEquivSum α β)).trans (mk_sum α β) instance : Mul Cardinal.{u} := - ⟨map₂ Prod fun _ _ _ _ => Equiv.prodCongr⟩ + fast_instance% ⟨map₂ Prod fun _ _ _ _ => Equiv.prodCongr⟩ theorem mul_def (α β : Type u) : #α * #β = #(α × β) := rfl diff --git a/Mathlib/SetTheory/ZFC/PSet.lean b/Mathlib/SetTheory/ZFC/PSet.lean index 70115837262919..361cf94a9826b7 100644 --- a/Mathlib/SetTheory/ZFC/PSet.lean +++ b/Mathlib/SetTheory/ZFC/PSet.lean @@ -110,7 +110,7 @@ protected theorem equiv_of_isEmpty (x y : PSet) [IsEmpty x.Type] [IsEmpty y.Type equiv_iff.2 <| by simp instance setoid : Setoid PSet := - ⟨PSet.Equiv, Equiv.refl, Equiv.symm, Equiv.trans⟩ + fast_instance% ⟨PSet.Equiv, Equiv.refl, Equiv.symm, Equiv.trans⟩ /-- A pre-set is a subset of another pre-set if every element of the first family is extensionally equivalent to some element of the second family. -/ diff --git a/Mathlib/Topology/Algebra/Constructions.lean b/Mathlib/Topology/Algebra/Constructions.lean index 307e68a576fa99..08940e227d640b 100644 --- a/Mathlib/Topology/Algebra/Constructions.lean +++ b/Mathlib/Topology/Algebra/Constructions.lean @@ -99,7 +99,7 @@ variable [TopologicalSpace M] [Monoid M] [TopologicalSpace N] [Monoid N] [Topolo @[to_additive /-- The additive units of a monoid are equipped with a topology, via the embedding into `M × M`. -/] instance instTopologicalSpaceUnits : TopologicalSpace Mˣ := - TopologicalSpace.induced (embedProduct M) inferInstance + fast_instance% TopologicalSpace.induced (embedProduct M) inferInstance @[to_additive] theorem isInducing_embedProduct : IsInducing (embedProduct M) := ⟨rfl⟩ diff --git a/Mathlib/Topology/Algebra/ContinuousAffineMap.lean b/Mathlib/Topology/Algebra/ContinuousAffineMap.lean index 7b17d45f64d353..50b4c372d27b23 100644 --- a/Mathlib/Topology/Algebra/ContinuousAffineMap.lean +++ b/Mathlib/Topology/Algebra/ContinuousAffineMap.lean @@ -270,7 +270,7 @@ instance [DistribMulAction Sᵐᵒᵖ W] [IsCentralScalar S W] : IsCentralScalar op_smul_eq_smul _ _ := ext fun _ ↦ op_smul_eq_smul _ _ instance : MulAction S (P →ᴬ[R] W) := - Function.Injective.mulAction _ coe_injective coe_smul + fast_instance% Function.Injective.mulAction _ coe_injective coe_smul variable [TopologicalSpace V] [IsTopologicalAddTorsor P] [IsTopologicalAddGroup W] @@ -312,12 +312,12 @@ instance : AddCommGroup (P →ᴬ[R] W) := instance [Monoid S] [DistribMulAction S W] [SMulCommClass R S W] [ContinuousConstSMul S W] : DistribMulAction S (P →ᴬ[R] W) := - Function.Injective.distribMulAction ⟨⟨fun f ↦ f.toAffineMap.toFun, rfl⟩, coe_add⟩ coe_injective + fast_instance% Function.Injective.distribMulAction ⟨⟨fun f ↦ f.toAffineMap.toFun, rfl⟩, coe_add⟩ coe_injective coe_smul instance [Semiring S] [Module S W] [SMulCommClass R S W] [ContinuousConstSMul S W] : Module S (P →ᴬ[R] W) := - Function.Injective.module S ⟨⟨fun f ↦ f.toAffineMap.toFun, rfl⟩, coe_add⟩ coe_injective coe_smul + fast_instance% Function.Injective.module S ⟨⟨fun f ↦ f.toAffineMap.toFun, rfl⟩, coe_add⟩ coe_injective coe_smul variable [TopologicalSpace V] [IsTopologicalAddTorsor P] diff --git a/Mathlib/Topology/Algebra/Group/ClosedSubgroup.lean b/Mathlib/Topology/Algebra/Group/ClosedSubgroup.lean index e0ae8b75fbc4c4..1bb2f126ed1c9c 100644 --- a/Mathlib/Topology/Algebra/Group/ClosedSubgroup.lean +++ b/Mathlib/Topology/Algebra/Group/ClosedSubgroup.lean @@ -82,7 +82,7 @@ instance instInfClosedSubgroup : Min (ClosedSubgroup G) := @[to_additive] instance instSemilatticeInfClosedSubgroup : SemilatticeInf (ClosedSubgroup G) := - SetLike.coe_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl + fast_instance% SetLike.coe_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl @[to_additive] instance [CompactSpace G] (H : ClosedSubgroup G) : CompactSpace H := diff --git a/Mathlib/Topology/Algebra/Group/CompactOpen.lean b/Mathlib/Topology/Algebra/Group/CompactOpen.lean index 36a25124e9fab8..bc76fb568f045e 100644 --- a/Mathlib/Topology/Algebra/Group/CompactOpen.lean +++ b/Mathlib/Topology/Algebra/Group/CompactOpen.lean @@ -28,7 +28,7 @@ namespace ContinuousMonoidHom @[to_additive] instance : TopologicalSpace (ContinuousMonoidHom A B) := - TopologicalSpace.induced toContinuousMap ContinuousMap.compactOpen + fast_instance% TopologicalSpace.induced toContinuousMap ContinuousMap.compactOpen @[to_additive] theorem isInducing_toContinuousMap : diff --git a/Mathlib/Topology/Algebra/Group/GroupTopology.lean b/Mathlib/Topology/Algebra/Group/GroupTopology.lean index 43dfdcf1f08f9c..c57948587905a0 100644 --- a/Mathlib/Topology/Algebra/Group/GroupTopology.lean +++ b/Mathlib/Topology/Algebra/Group/GroupTopology.lean @@ -81,7 +81,7 @@ in `t` (`t` is finer than `s`). -/ /-- The ordering on group topologies on the group `γ`. `t ≤ s` if every set open in `s` is also open in `t` (`t` is finer than `s`). -/] instance : PartialOrder (GroupTopology α) := - PartialOrder.lift toTopologicalSpace toTopologicalSpace_injective + fast_instance% PartialOrder.lift toTopologicalSpace toTopologicalSpace_injective @[to_additive (attr := simp)] theorem toTopologicalSpace_le {x y : GroupTopology α} : diff --git a/Mathlib/Topology/Algebra/Module/ContinuousLinearMap/Basic.lean b/Mathlib/Topology/Algebra/Module/ContinuousLinearMap/Basic.lean index f723511488ea9e..58c065445301cb 100644 --- a/Mathlib/Topology/Algebra/Module/ContinuousLinearMap/Basic.lean +++ b/Mathlib/Topology/Algebra/Module/ContinuousLinearMap/Basic.lean @@ -665,7 +665,7 @@ variable [ContinuousAdd M₁] This generalizes `Function.End.applyMulAction`. -/ instance applyModule : Module (M₁ →L[R₁] M₁) M₁ := - Module.compHom _ toLinearMapRingHom + fast_instance% Module.compHom _ toLinearMapRingHom @[simp] protected theorem smul_def (f : M₁ →L[R₁] M₁) (a : M₁) : f • a = f a := diff --git a/Mathlib/Topology/Algebra/Module/Spaces/WeakBilin.lean b/Mathlib/Topology/Algebra/Module/Spaces/WeakBilin.lean index 1f7fa9d634c3e0..370164a0f6777a 100644 --- a/Mathlib/Topology/Algebra/Module/Spaces/WeakBilin.lean +++ b/Mathlib/Topology/Algebra/Module/Spaces/WeakBilin.lean @@ -86,7 +86,7 @@ variable [AddCommMonoid F] [Module 𝕜 F] variable (B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜) instance instTopologicalSpace : TopologicalSpace (WeakBilin B) := - TopologicalSpace.induced (fun x y => B x y) Pi.topologicalSpace + fast_instance% TopologicalSpace.induced (fun x y => B x y) Pi.topologicalSpace /-- The coercion `(fun x y => B x y) : E → (F → 𝕜)` is continuous. -/ theorem coeFn_continuous : Continuous fun (x : WeakBilin B) y => B x y := diff --git a/Mathlib/Topology/Algebra/OpenSubgroup.lean b/Mathlib/Topology/Algebra/OpenSubgroup.lean index fc2f06b4987b35..983d910ba1f73f 100644 --- a/Mathlib/Topology/Algebra/OpenSubgroup.lean +++ b/Mathlib/Topology/Algebra/OpenSubgroup.lean @@ -196,7 +196,7 @@ instance instPartialOrderOpenSubgroup : PartialOrder (OpenSubgroup G) := inferIn -- We override `toPartialorder` to get better `le` @[to_additive] instance instSemilatticeInfOpenSubgroup : SemilatticeInf (OpenSubgroup G) := - SetLike.coe_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl + fast_instance% SetLike.coe_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl @[to_additive] instance : OrderTop (OpenSubgroup G) where @@ -419,7 +419,7 @@ instance instInfOpenNormalSubgroup : Min (OpenNormalSubgroup G) := @[to_additive] instance instSemilatticeInfOpenNormalSubgroup : SemilatticeInf (OpenNormalSubgroup G) := - SetLike.coe_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl + fast_instance% SetLike.coe_injective.semilatticeInf _ .rfl .rfl fun _ _ ↦ rfl @[to_additive] instance [SeparatelyContinuousMul G] : Max (OpenNormalSubgroup G) := diff --git a/Mathlib/Topology/Algebra/RestrictedProduct/Basic.lean b/Mathlib/Topology/Algebra/RestrictedProduct/Basic.lean index f818f427f99324..82fbd288f77d6a 100644 --- a/Mathlib/Topology/Algebra/RestrictedProduct/Basic.lean +++ b/Mathlib/Topology/Algebra/RestrictedProduct/Basic.lean @@ -254,12 +254,12 @@ lemma pow_apply [Π i, Monoid (R i)] [∀ i, SubmonoidClass (S i) (R i)] @[to_additive] instance [Π i, Monoid (R i)] [∀ i, SubmonoidClass (S i) (R i)] : Monoid (Πʳ i, [R i, B i]_[𝓕]) := - DFunLike.coe_injective.monoid _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + fast_instance% DFunLike.coe_injective.monoid _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) @[to_additive] instance [Π i, CommMonoid (R i)] [∀ i, SubmonoidClass (S i) (R i)] : CommMonoid (Πʳ i, [R i, B i]_[𝓕]) := - DFunLike.coe_injective.commMonoid _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + fast_instance% DFunLike.coe_injective.commMonoid _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) @[to_additive] instance instZPow [Π i, DivInvMonoid (R i)] [∀ i, SubgroupClass (S i) (R i)] : @@ -278,13 +278,13 @@ instance [Π i, AddMonoidWithOne (R i)] [∀ i, AddSubmonoidWithOneClass (S i) ( @[to_additive] instance [Π i, Group (R i)] [∀ i, SubgroupClass (S i) (R i)] : Group (Πʳ i, [R i, B i]_[𝓕]) := - DFunLike.coe_injective.group _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + fast_instance% DFunLike.coe_injective.group _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) @[to_additive] instance [Π i, CommGroup (R i)] [∀ i, SubgroupClass (S i) (R i)] : CommGroup (Πʳ i, [R i, B i]_[𝓕]) := - DFunLike.coe_injective.commGroup _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + fast_instance% DFunLike.coe_injective.commGroup _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) instance [Π i, Ring (R i)] [∀ i, SubringClass (S i) (R i)] : @@ -293,7 +293,7 @@ instance [Π i, Ring (R i)] [∀ i, SubringClass (S i) (R i)] : instance [Π i, Ring (R i)] [∀ i, SubringClass (S i) (R i)] : Ring (Πʳ i, [R i, B i]_[𝓕]) := - DFunLike.coe_injective.ring _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + fast_instance% DFunLike.coe_injective.ring _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) instance [Π i, CommRing (R i)] [∀ i, SubringClass (S i) (R i)] : @@ -314,7 +314,7 @@ def coeMonoidHom [∀ i, Monoid (R i)] [∀ i, SubmonoidClass (S i) (R i)] : instance {R₀ : Type*} [Semiring R₀] [Π i, AddCommMonoid (R i)] [Π i, Module R₀ (R i)] [∀ i, AddSubmonoidClass (S i) (R i)] [∀ i, SMulMemClass (S i) R₀ (R i)] : Module R₀ (Πʳ i, [R i, B i]_[𝓕]) := - DFunLike.coe_injective.module R₀ (M := Π i, R i) coeAddMonoidHom (fun _ _ ↦ rfl) + fast_instance% DFunLike.coe_injective.module R₀ (M := Π i, R i) coeAddMonoidHom (fun _ _ ↦ rfl) end Algebra diff --git a/Mathlib/Topology/Algebra/Ring/Basic.lean b/Mathlib/Topology/Algebra/Ring/Basic.lean index 83f775a32f24ea..c5257e5bb116c6 100644 --- a/Mathlib/Topology/Algebra/Ring/Basic.lean +++ b/Mathlib/Topology/Algebra/Ring/Basic.lean @@ -531,7 +531,7 @@ theorem ext {f g : RingTopology R} (h : f.IsOpen = g.IsOpen) : f = g := /-- The ordering on ring topologies on the ring `R`. `t ≤ s` if every set open in `s` is also open in `t` (`t` is finer than `s`). -/ instance : PartialOrder (RingTopology R) := - PartialOrder.lift RingTopology.toTopologicalSpace toTopologicalSpace_injective + fast_instance% PartialOrder.lift RingTopology.toTopologicalSpace toTopologicalSpace_injective set_option backward.privateInPublic true in private def def_sInf (S : Set (RingTopology R)) : RingTopology R := diff --git a/Mathlib/Topology/Bornology/Constructions.lean b/Mathlib/Topology/Bornology/Constructions.lean index 8097fab3d59cec..e3bac6162850c3 100644 --- a/Mathlib/Topology/Bornology/Constructions.lean +++ b/Mathlib/Topology/Bornology/Constructions.lean @@ -41,7 +41,7 @@ abbrev Bornology.induced {α β : Type*} [Bornology β] (f : α → β) : Bornol le_cofinite := (comap_mono (Bornology.le_cofinite β)).trans (comap_cofinite_le _) instance {p : α → Prop} : Bornology (Subtype p) := - Bornology.induced (Subtype.val : Subtype p → α) + fast_instance% Bornology.induced (Subtype.val : Subtype p → α) namespace Bornology diff --git a/Mathlib/Topology/Connected/PathConnected.lean b/Mathlib/Topology/Connected/PathConnected.lean index 46e8b52415fa8e..9f32056b942aed 100644 --- a/Mathlib/Topology/Connected/PathConnected.lean +++ b/Mathlib/Topology/Connected/PathConnected.lean @@ -137,7 +137,7 @@ lemma isQuotientMap_mk : IsQuotientMap (ZerothHomotopy.mk (X := X)) := isQuotientMap_quotient_mk' instance inhabited : Inhabited (ZerothHomotopy ℝ) := - ⟨@Quotient.mk' ℝ (pathSetoid ℝ) 0⟩ + fast_instance% ⟨@Quotient.mk' ℝ (pathSetoid ℝ) 0⟩ instance [Nonempty X] : Nonempty (ZerothHomotopy X) := ⟨.mk (Classical.arbitrary _)⟩ diff --git a/Mathlib/Topology/ContinuousMap/Bounded/Normed.lean b/Mathlib/Topology/ContinuousMap/Bounded/Normed.lean index e3d1fa222d25b2..fb2e91c917001c 100644 --- a/Mathlib/Topology/ContinuousMap/Bounded/Normed.lean +++ b/Mathlib/Topology/ContinuousMap/Bounded/Normed.lean @@ -514,7 +514,7 @@ instance instSMul' : SMul (α →ᵇ 𝕜) (α →ᵇ β) where mul_le_mul (f.norm_coe_le_norm _) (g.norm_coe_le_norm _) (norm_nonneg _) (norm_nonneg _) instance instModule' : Module (α →ᵇ 𝕜) (α →ᵇ β) := - Module.ofMinimalAxioms + fast_instance% Module.ofMinimalAxioms (fun c _ _ => ext fun a => smul_add (c a) _ _) (fun _ _ _ => ext fun _ => add_smul _ _ _) (fun _ _ _ => ext fun _ => mul_smul _ _ _) @@ -535,7 +535,7 @@ variable [TopologicalSpace α] [NormedAddCommGroup β] [Lattice β] [HasSolidNorm β] [IsOrderedAddMonoid β] instance instPartialOrder : PartialOrder (α →ᵇ β) := - PartialOrder.lift (fun f => f.toFun) (by simp [Injective]) + fast_instance% PartialOrder.lift (fun f => f.toFun) (by simp [Injective]) instance instSup : Max (α →ᵇ β) where max f g := diff --git a/Mathlib/Topology/EMetricSpace/Defs.lean b/Mathlib/Topology/EMetricSpace/Defs.lean index 44fa6e9c5e5d8f..eaa3c3d2f2a38b 100644 --- a/Mathlib/Topology/EMetricSpace/Defs.lean +++ b/Mathlib/Topology/EMetricSpace/Defs.lean @@ -322,7 +322,7 @@ abbrev PseudoEMetricSpace.induced {α β} (f : α → β) (m : PseudoEMetricSpac /-- Pseudoemetric space instance on subsets of pseudoemetric spaces -/ instance {α : Type*} {p : α → Prop} [PseudoEMetricSpace α] : PseudoEMetricSpace (Subtype p) := - PseudoEMetricSpace.induced Subtype.val ‹_› + fast_instance% PseudoEMetricSpace.induced Subtype.val ‹_› /-- The extended pseudodistance on a subset of a pseudoemetric space is the restriction of the original pseudodistance, by definition. -/ @@ -359,7 +359,7 @@ namespace MulOpposite @[to_additive /-- Pseudoemetric space instance on the additive opposite of a pseudoemetric space. -/] instance {α : Type*} [PseudoEMetricSpace α] : PseudoEMetricSpace αᵐᵒᵖ := - PseudoEMetricSpace.induced unop ‹_› + fast_instance% PseudoEMetricSpace.induced unop ‹_› @[to_additive] theorem edist_unop (x y : αᵐᵒᵖ) : edist (unop x) (unop y) = edist x y := rfl @@ -371,7 +371,7 @@ end MulOpposite section ULift -instance : PseudoEMetricSpace (ULift α) := PseudoEMetricSpace.induced ULift.down ‹_› +instance : PseudoEMetricSpace (ULift α) := fast_instance% PseudoEMetricSpace.induced ULift.down ‹_› theorem ULift.edist_eq (x y : ULift α) : edist x y = edist x.down y.down := rfl @@ -813,15 +813,15 @@ abbrev EMetricSpace.induced {γ β} (f : γ → β) (hf : Function.Injective f) /-- EMetric space instance on subsets of emetric spaces -/ instance {α : Type*} {p : α → Prop} [EMetricSpace α] : EMetricSpace (Subtype p) := - EMetricSpace.induced Subtype.val Subtype.coe_injective ‹_› + fast_instance% EMetricSpace.induced Subtype.val Subtype.coe_injective ‹_› /-- EMetric space instance on the multiplicative opposite of an emetric space. -/ @[to_additive /-- EMetric space instance on the additive opposite of an emetric space. -/] instance {α : Type*} [EMetricSpace α] : EMetricSpace αᵐᵒᵖ := - EMetricSpace.induced MulOpposite.unop MulOpposite.unop_injective ‹_› + fast_instance% EMetricSpace.induced MulOpposite.unop MulOpposite.unop_injective ‹_› instance {α : Type*} [EMetricSpace α] : EMetricSpace (ULift α) := - EMetricSpace.induced ULift.down ULift.down_injective ‹_› + fast_instance% EMetricSpace.induced ULift.down ULift.down_injective ‹_› /-- Reformulation of the uniform structure in terms of the extended distance -/ theorem uniformity_edist : 𝓤 γ = ⨅ ε > 0, 𝓟 { p : γ × γ | edist p.1 p.2 < ε } := @@ -993,7 +993,7 @@ abbrev WeakEMetricSpace.induced /-- `WeakEMetricSpace` instance on subsets of emetric spaces -/ instance {α : Type*} {p : α → Prop} [TopologicalSpace α] [WeakEMetricSpace α] : WeakEMetricSpace (Subtype p) := - WeakEMetricSpace.induced Subtype.coe_injective ‹_› + fast_instance% WeakEMetricSpace.induced Subtype.coe_injective ‹_› end diff --git a/Mathlib/Topology/FiberBundle/Constructions.lean b/Mathlib/Topology/FiberBundle/Constructions.lean index cb6efb03ba94e4..6a9bc573e1a93b 100644 --- a/Mathlib/Topology/FiberBundle/Constructions.lean +++ b/Mathlib/Topology/FiberBundle/Constructions.lean @@ -103,7 +103,7 @@ variable [TopologicalSpace (TotalSpace F₁ E₁)] [TopologicalSpace (TotalSpace /-- Equip the total space of the fiberwise product of two fiber bundles `E₁`, `E₂` with the induced topology from the diagonal embedding into `TotalSpace F₁ E₁ × TotalSpace F₂ E₂`. -/ instance FiberBundle.Prod.topologicalSpace : TopologicalSpace (TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂)) := - TopologicalSpace.induced + fast_instance% TopologicalSpace.induced (fun p ↦ ((⟨p.1, p.2.1⟩ : TotalSpace F₁ E₁), (⟨p.1, p.2.2⟩ : TotalSpace F₂ E₂))) inferInstance diff --git a/Mathlib/Topology/Homotopy/HomotopyGroup.lean b/Mathlib/Topology/Homotopy/HomotopyGroup.lean index c2ed2c6f3659f8..2b4db70704abad 100644 --- a/Mathlib/Topology/Homotopy/HomotopyGroup.lean +++ b/Mathlib/Topology/Homotopy/HomotopyGroup.lean @@ -596,7 +596,7 @@ theorem inv_spec [Nonempty N] {i} {p : Ω^ N X x} : /-- Multiplication on `HomotopyGroup N X x` is commutative for nontrivial `N`. In particular, multiplication on `π_(n+2)` is commutative. -/ instance commGroup [Nontrivial N] : CommGroup (HomotopyGroup N X x) := - let h := exists_ne (Classical.arbitrary N) + fast_instance% let h := exists_ne (Classical.arbitrary N) fast_instance% @EckmannHilton.commGroup (HomotopyGroup N X x) _ 1 (isUnital_auxGroup <| Classical.choose h) _ (by diff --git a/Mathlib/Topology/Homotopy/Path.lean b/Mathlib/Topology/Homotopy/Path.lean index 1055835b65e55b..368703a20f1e02 100644 --- a/Mathlib/Topology/Homotopy/Path.lean +++ b/Mathlib/Topology/Homotopy/Path.lean @@ -297,7 +297,7 @@ protected def Quotient (x₀ x₁ : X) := attribute [local instance] Homotopic.setoid instance : Inhabited (Homotopic.Quotient () ()) := - ⟨Quotient.mk' <| Path.refl ()⟩ + fast_instance% ⟨Quotient.mk' <| Path.refl ()⟩ namespace Quotient diff --git a/Mathlib/Topology/LocallyConstant/Algebra.lean b/Mathlib/Topology/LocallyConstant/Algebra.lean index a1c3a4ec8f377b..6f96a4ac7ecbdb 100644 --- a/Mathlib/Topology/LocallyConstant/Algebra.lean +++ b/Mathlib/Topology/LocallyConstant/Algebra.lean @@ -60,7 +60,7 @@ theorem mul_apply [Mul Y] (f g : LocallyConstant X Y) (x : X) : (f * g) x = f x @[to_additive] instance [MulOneClass Y] : MulOneClass (LocallyConstant X Y) := - Function.Injective.mulOneClass DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl + fast_instance% Function.Injective.mulOneClass DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl /-- `DFunLike.coe` as a `MonoidHom`. -/ @[to_additive (attr := simps) /-- `DFunLike.coe` as an `AddMonoidHom`. -/] @@ -77,10 +77,10 @@ def constMonoidHom [MulOneClass Y] : Y →* LocallyConstant X Y where map_mul' _ _ := rfl instance [MulZeroClass Y] : MulZeroClass (LocallyConstant X Y) := - Function.Injective.mulZeroClass DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl + fast_instance% Function.Injective.mulZeroClass DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl instance [MulZeroOneClass Y] : MulZeroOneClass (LocallyConstant X Y) := - Function.Injective.mulZeroOneClass DFunLike.coe DFunLike.coe_injective' rfl rfl fun _ _ => rfl + fast_instance% Function.Injective.mulZeroOneClass DFunLike.coe DFunLike.coe_injective' rfl rfl fun _ _ => rfl section CharFn @@ -120,14 +120,14 @@ theorem div_apply [Div Y] (f g : LocallyConstant X Y) (x : X) : (f / g) x = f x @[to_additive] instance [Semigroup Y] : Semigroup (LocallyConstant X Y) := - Function.Injective.semigroup DFunLike.coe DFunLike.coe_injective' fun _ _ => rfl + fast_instance% Function.Injective.semigroup DFunLike.coe DFunLike.coe_injective' fun _ _ => rfl instance [SemigroupWithZero Y] : SemigroupWithZero (LocallyConstant X Y) := - Function.Injective.semigroupWithZero DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl + fast_instance% Function.Injective.semigroupWithZero DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl @[to_additive] instance [CommSemigroup Y] : CommSemigroup (LocallyConstant X Y) := - Function.Injective.commSemigroup DFunLike.coe DFunLike.coe_injective' fun _ _ => rfl + fast_instance% Function.Injective.commSemigroup DFunLike.coe DFunLike.coe_injective' fun _ _ => rfl variable {α R : Type*} @@ -149,7 +149,7 @@ instance [Pow Y α] : Pow (LocallyConstant X Y) α where @[to_additive] instance [Monoid Y] : Monoid (LocallyConstant X Y) := - Function.Injective.monoid DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Function.Injective.monoid DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) fun _ _ => rfl instance [NatCast Y] : NatCast (LocallyConstant X Y) where natCast n := const X n @@ -158,37 +158,37 @@ instance [IntCast Y] : IntCast (LocallyConstant X Y) where intCast n := const X n instance [AddMonoidWithOne Y] : AddMonoidWithOne (LocallyConstant X Y) := - Function.Injective.addMonoidWithOne DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) + fast_instance% Function.Injective.addMonoidWithOne DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl @[to_additive] instance [CommMonoid Y] : CommMonoid (LocallyConstant X Y) := - Function.Injective.commMonoid DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.commMonoid DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) fun _ _ => rfl @[to_additive] instance [Group Y] : Group (LocallyConstant X Y) := - Function.Injective.group DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.group DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) @[to_additive] instance [CommGroup Y] : CommGroup (LocallyConstant X Y) := - Function.Injective.commGroup DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.commGroup DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [Distrib Y] : Distrib (LocallyConstant X Y) := - Function.Injective.distrib DFunLike.coe DFunLike.coe_injective' (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Function.Injective.distrib DFunLike.coe DFunLike.coe_injective' (fun _ _ => rfl) fun _ _ => rfl instance [NonUnitalNonAssocSemiring Y] : NonUnitalNonAssocSemiring (LocallyConstant X Y) := - Function.Injective.nonUnitalNonAssocSemiring DFunLike.coe DFunLike.coe_injective' rfl + fast_instance% Function.Injective.nonUnitalNonAssocSemiring DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonUnitalSemiring Y] : NonUnitalSemiring (LocallyConstant X Y) := - Function.Injective.nonUnitalSemiring DFunLike.coe DFunLike.coe_injective' rfl + fast_instance% Function.Injective.nonUnitalSemiring DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonAssocSemiring Y] : NonAssocSemiring (LocallyConstant X Y) := - Function.Injective.nonAssocSemiring DFunLike.coe DFunLike.coe_injective' rfl rfl + fast_instance% Function.Injective.nonAssocSemiring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl /-- The constant-function embedding, as a ring hom. -/ @@ -197,55 +197,55 @@ def constRingHom [NonAssocSemiring Y] : Y →+* LocallyConstant X Y := { constMonoidHom, constAddMonoidHom with toFun := const X } instance [Semiring Y] : Semiring (LocallyConstant X Y) := - Function.Injective.semiring DFunLike.coe DFunLike.coe_injective' rfl rfl + fast_instance% Function.Injective.semiring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl instance [NonUnitalCommSemiring Y] : NonUnitalCommSemiring (LocallyConstant X Y) := - Function.Injective.nonUnitalCommSemiring DFunLike.coe DFunLike.coe_injective' rfl + fast_instance% Function.Injective.nonUnitalCommSemiring DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [CommSemiring Y] : CommSemiring (LocallyConstant X Y) := - Function.Injective.commSemiring DFunLike.coe DFunLike.coe_injective' rfl rfl + fast_instance% Function.Injective.commSemiring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl instance [NonUnitalNonAssocRing Y] : NonUnitalNonAssocRing (LocallyConstant X Y) := - Function.Injective.nonUnitalNonAssocRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.nonUnitalNonAssocRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonUnitalRing Y] : NonUnitalRing (LocallyConstant X Y) := - Function.Injective.nonUnitalRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.nonUnitalRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonAssocRing Y] : NonAssocRing (LocallyConstant X Y) := - Function.Injective.nonAssocRing DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) + fast_instance% Function.Injective.nonAssocRing DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ => rfl) instance [Ring Y] : Ring (LocallyConstant X Y) := - Function.Injective.ring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) + fast_instance% Function.Injective.ring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) fun _ => rfl instance [NonUnitalCommRing Y] : NonUnitalCommRing (LocallyConstant X Y) := - Function.Injective.nonUnitalCommRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.nonUnitalCommRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [CommRing Y] : CommRing (LocallyConstant X Y) := - Function.Injective.commRing DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) + fast_instance% Function.Injective.commRing DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) fun _ => rfl variable {R : Type*} instance [Monoid R] [MulAction R Y] : MulAction R (LocallyConstant X Y) := - Function.Injective.mulAction _ coe_injective fun _ _ => rfl + fast_instance% Function.Injective.mulAction _ coe_injective fun _ _ => rfl instance [Monoid R] [AddMonoid Y] [DistribMulAction R Y] : DistribMulAction R (LocallyConstant X Y) := - Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective fun _ _ => rfl + fast_instance% Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective fun _ _ => rfl instance [Semiring R] [AddCommMonoid Y] [Module R Y] : Module R (LocallyConstant X Y) := - Function.Injective.module R coeFnAddMonoidHom coe_injective fun _ _ => rfl + fast_instance% Function.Injective.module R coeFnAddMonoidHom coe_injective fun _ _ => rfl section Algebra diff --git a/Mathlib/Topology/MetricSpace/Basic.lean b/Mathlib/Topology/MetricSpace/Basic.lean index a254c5c87e1000..500c3b0286e507 100644 --- a/Mathlib/Topology/MetricSpace/Basic.lean +++ b/Mathlib/Topology/MetricSpace/Basic.lean @@ -114,7 +114,7 @@ instance Subtype.metricSpace {α : Type*} {p : α → Prop} [MetricSpace α] : @[to_additive] instance MulOpposite.instMetricSpace {α : Type*} [MetricSpace α] : MetricSpace αᵐᵒᵖ := - MetricSpace.induced MulOpposite.unop MulOpposite.unop_injective ‹_› + fast_instance% MetricSpace.induced MulOpposite.unop MulOpposite.unop_injective ‹_› section Real diff --git a/Mathlib/Topology/MetricSpace/Bilipschitz.lean b/Mathlib/Topology/MetricSpace/Bilipschitz.lean index 9b91e1169e3d55..edae09bce2c386 100644 --- a/Mathlib/Topology/MetricSpace/Bilipschitz.lean +++ b/Mathlib/Topology/MetricSpace/Bilipschitz.lean @@ -91,7 +91,7 @@ instance : Bornology α := inferInstanceAs (Bornology β) ``` Users should instead write something like: ``` -instance : Bornology α := Bornology.induced (f : α → β) +instance : Bornology α := fast_instance% Bornology.induced (f : α → β) ``` in order to avoid abuse of the definitional equality `α := β`. -/ lemma isBounded_iff_of_bilipschitz (hf₁ : AntilipschitzWith K₁ f) (hf₂ : LipschitzWith K₂ f) diff --git a/Mathlib/Topology/MetricSpace/Pseudo/Constructions.lean b/Mathlib/Topology/MetricSpace/Pseudo/Constructions.lean index b8c6b9bf74083b..0defc771f85fbf 100644 --- a/Mathlib/Topology/MetricSpace/Pseudo/Constructions.lean +++ b/Mathlib/Topology/MetricSpace/Pseudo/Constructions.lean @@ -58,7 +58,7 @@ namespace Subtype variable {p : α → Prop} instance pseudoMetricSpace : PseudoMetricSpace (Subtype p) := - PseudoMetricSpace.induced Subtype.val ‹_› + fast_instance% PseudoMetricSpace.induced Subtype.val ‹_› lemma dist_eq (x y : Subtype p) : dist x y = dist (x : α) y := rfl @@ -89,7 +89,7 @@ namespace MulOpposite @[to_additive] instance instPseudoMetricSpace : PseudoMetricSpace αᵐᵒᵖ := - PseudoMetricSpace.induced MulOpposite.unop ‹_› + fast_instance% PseudoMetricSpace.induced MulOpposite.unop ‹_› @[to_additive (attr := simp)] lemma dist_unop (x y : αᵐᵒᵖ) : dist (unop x) (unop y) = dist x y := rfl diff --git a/Mathlib/Topology/Order/Hom/Basic.lean b/Mathlib/Topology/Order/Hom/Basic.lean index 1420bfa7e6cdd3..f608ce7bb88894 100644 --- a/Mathlib/Topology/Order/Hom/Basic.lean +++ b/Mathlib/Topology/Order/Hom/Basic.lean @@ -175,12 +175,12 @@ theorem cancel_left {g : β →Co γ} {f₁ f₂ : α →Co β} (hg : Injective ⟨fun h => ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩ instance : Preorder (α →Co β) := - Preorder.lift ((↑) : (α →Co β) → α → β) + fast_instance% Preorder.lift ((↑) : (α →Co β) → α → β) end Preorder instance [PartialOrder β] : PartialOrder (α →Co β) := - PartialOrder.lift ((↑) : (α →Co β) → α → β) DFunLike.coe_injective + fast_instance% PartialOrder.lift ((↑) : (α →Co β) → α → β) DFunLike.coe_injective end ContinuousOrderHom diff --git a/Mathlib/Topology/Sets/Order.lean b/Mathlib/Topology/Sets/Order.lean index 3f9f3656e70492..cbddb055260533 100644 --- a/Mathlib/Topology/Sets/Order.lean +++ b/Mathlib/Topology/Sets/Order.lean @@ -75,10 +75,10 @@ instance : Bot (ClopenUpperSet α) := ⟨⟨⊥, isUpperSet_empty⟩⟩ instance : Lattice (ClopenUpperSet α) := - SetLike.coe_injective.lattice _ .rfl .rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl + fast_instance% SetLike.coe_injective.lattice _ .rfl .rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance : BoundedOrder (ClopenUpperSet α) := - BoundedOrder.lift ((↑) : _ → Set α) (fun _ _ => id) rfl rfl + fast_instance% BoundedOrder.lift ((↑) : _ → Set α) (fun _ _ => id) rfl rfl @[simp] theorem coe_sup (s t : ClopenUpperSet α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t := diff --git a/Mathlib/Topology/Sheaves/CommRingCat.lean b/Mathlib/Topology/Sheaves/CommRingCat.lean index 58124e187e0c0c..6a08c856490584 100644 --- a/Mathlib/Topology/Sheaves/CommRingCat.lean +++ b/Mathlib/Topology/Sheaves/CommRingCat.lean @@ -198,7 +198,7 @@ instance : Pow (X ⟶ (forget₂ TopCommRingCat TopCat).obj R) ℕ where pow f n := ofHom (f.hom ^ n) instance : CommRing (X ⟶ (forget₂ TopCommRingCat TopCat).obj R) := - Function.Injective.commRing _ ConcreteCategory.hom_injective + fast_instance% Function.Injective.commRing _ ConcreteCategory.hom_injective rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ => rfl) diff --git a/Mathlib/Topology/UniformSpace/Basic.lean b/Mathlib/Topology/UniformSpace/Basic.lean index 890f5efd1ed61d..9300d7abbf0ca9 100644 --- a/Mathlib/Topology/UniformSpace/Basic.lean +++ b/Mathlib/Topology/UniformSpace/Basic.lean @@ -322,7 +322,7 @@ open uniformity section Constructions instance : PartialOrder (UniformSpace α) := - PartialOrder.lift (fun u => 𝓤[u]) fun _ _ => UniformSpace.ext + fast_instance% PartialOrder.lift (fun u => 𝓤[u]) fun _ _ => UniformSpace.ext protected theorem UniformSpace.le_def {u₁ u₂ : UniformSpace α} : u₁ ≤ u₂ ↔ 𝓤[u₁] ≤ 𝓤[u₂] := Iff.rfl From abe410a17ea5bfbe668bac69bea07ffa8ed41df7 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 00:22:53 +0200 Subject: [PATCH 08/30] long line --- Mathlib/GroupTheory/GroupAction/DomAct/Basic.lean | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mathlib/GroupTheory/GroupAction/DomAct/Basic.lean b/Mathlib/GroupTheory/GroupAction/DomAct/Basic.lean index 7c2cecc301d04c..47e1c225f9b656 100644 --- a/Mathlib/GroupTheory/GroupAction/DomAct/Basic.lean +++ b/Mathlib/GroupTheory/GroupAction/DomAct/Basic.lean @@ -223,7 +223,8 @@ theorem smul_monoidHom_apply (c : Mᵈᵐᵃ) (f : A →* B) (a : A) : (c • f) @[simp] theorem mk_smul_monoidHom_apply (c : M) (f : A →* B) (a : A) : (mk c • f) a = f (c • a) := rfl -instance : MulAction Mᵈᵐᵃ (A →* B) := fast_instance% DFunLike.coe_injective.mulAction (⇑) fun _ _ ↦ rfl +instance : MulAction Mᵈᵐᵃ (A →* B) := fast_instance% + DFunLike.coe_injective.mulAction (⇑) fun _ _ ↦ rfl end MonoidHom From dd22ac05bf04c8b43d786a7aecf7b83fbe4ae5b8 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 00:33:37 +0200 Subject: [PATCH 09/30] fix remaining long lines from fast_instance% sweep --- .../AlgebraicGeometry/IdealSheaf/Basic.lean | 3 +- .../ProjectiveSpectrum/Topology.lean | 3 +- .../BoxIntegral/Partition/Additive.lean | 3 +- Mathlib/Analysis/Normed/Field/UnitBall.lean | 9 ++-- .../Analysis/Normed/Group/SemiNormedGrp.lean | 3 +- .../Enumerative/IncidenceAlgebra.lean | 12 +++-- .../SimpleGraph/Finsubgraph.lean | 6 ++- Mathlib/Combinatorics/Young/YoungDiagram.lean | 3 +- Mathlib/Data/DFinsupp/Defs.lean | 6 ++- Mathlib/Data/DFinsupp/Module.lean | 3 +- Mathlib/Data/Finsupp/Pointwise.lean | 12 +++-- Mathlib/Data/Fintype/Sigma.lean | 3 +- Mathlib/Geometry/Diffeology/Basic.lean | 3 +- .../GroupTheory/GroupAction/SubMulAction.lean | 3 +- .../LinearAlgebra/QuadraticForm/Basic.lean | 3 +- Mathlib/Logic/Encodable/Pi.lean | 3 +- .../MeasureTheory/Function/SimpleFunc.lean | 3 +- .../MeasurableSpace/MeasurablyGenerated.lean | 3 +- .../MeasureTheory/Measure/FiniteMeasure.lean | 3 +- .../MeasureTheory/VectorMeasure/Basic.lean | 3 +- .../ModularForms/SlashInvariantForms.lean | 3 +- Mathlib/Order/UpperLower/CompleteLattice.lean | 3 +- Mathlib/RingTheory/FractionalIdeal/Basic.lean | 3 +- .../Topology/Algebra/ContinuousAffineMap.lean | 6 ++- .../Algebra/RestrictedProduct/Basic.lean | 3 +- Mathlib/Topology/LocallyConstant/Algebra.lean | 51 ++++++++++++------- 26 files changed, 106 insertions(+), 53 deletions(-) diff --git a/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean b/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean index 49f646344f438f..32095d713aed09 100644 --- a/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean +++ b/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean @@ -85,7 +85,8 @@ protected lemma ext {I J : X.IdealSheafData} (h : I.ideal = J.ideal) : I = J := section Order -instance : PartialOrder (IdealSheafData X) := fast_instance% PartialOrder.lift ideal fun _ _ ↦ IdealSheafData.ext +instance : PartialOrder (IdealSheafData X) := fast_instance% + PartialOrder.lift ideal fun _ _ ↦ IdealSheafData.ext lemma le_def {I J : IdealSheafData X} : I ≤ J ↔ ∀ U, I.ideal U ≤ J.ideal U := .rfl diff --git a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean index fb6dae4663f657..03c614569fb84b 100644 --- a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean +++ b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean @@ -413,7 +413,8 @@ where `x ≤ y` if and only if `y ∈ closure {x}`. instance : PartialOrder (ProjectiveSpectrum 𝒜) := - fast_instance% PartialOrder.lift asHomogeneousIdeal fun ⟨_, _, _⟩ ⟨_, _, _⟩ => by simp only [mk.injEq, imp_self] + fast_instance% PartialOrder.lift asHomogeneousIdeal + fun ⟨_, _, _⟩ ⟨_, _, _⟩ => by simp only [mk.injEq, imp_self] @[simp] theorem as_ideal_le_as_ideal (x y : ProjectiveSpectrum 𝒜) : diff --git a/Mathlib/Analysis/BoxIntegral/Partition/Additive.lean b/Mathlib/Analysis/BoxIntegral/Partition/Additive.lean index a43ed6bd785205..c235f2ba793e14 100644 --- a/Mathlib/Analysis/BoxIntegral/Partition/Additive.lean +++ b/Mathlib/Analysis/BoxIntegral/Partition/Additive.lean @@ -99,7 +99,8 @@ instance {R} [Monoid R] [DistribMulAction R M] : SMul R (ι →ᵇᵃ[I₀] M) : simp only [Pi.smul_apply, ← smul_sum, sum_partition_boxes _ hI hπ]⟩⟩ instance : AddCommMonoid (ι →ᵇᵃ[I₀] M) := - fast_instance% Function.Injective.addCommMonoid _ coe_injective rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Function.Injective.addCommMonoid _ coe_injective rfl (fun _ _ => rfl) + fun _ _ => rfl @[simp] theorem map_split_add (f : ι →ᵇᵃ[I₀] M) (hI : ↑I ≤ I₀) (i : ι) (x : ℝ) : diff --git a/Mathlib/Analysis/Normed/Field/UnitBall.lean b/Mathlib/Analysis/Normed/Field/UnitBall.lean index 6fcfb8adaf6afe..383f9f1575f7a9 100644 --- a/Mathlib/Analysis/Normed/Field/UnitBall.lean +++ b/Mathlib/Analysis/Normed/Field/UnitBall.lean @@ -52,7 +52,8 @@ instance Metric.unitBall.instCommSemigroup [SeminormedCommRing 𝕜] : instance Metric.unitBall.instHasDistribNeg [NonUnitalSeminormedRing 𝕜] : HasDistribNeg (ball (0 : 𝕜) 1) := - fast_instance% Subtype.coe_injective.hasDistribNeg ((↑) : ball (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl + fast_instance% Subtype.coe_injective.hasDistribNeg ((↑) : ball (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) + fun _ _ => rfl @[simp, norm_cast] protected theorem Metric.unitBall.coe_mul [NonUnitalSeminormedRing 𝕜] (x y : ball (0 : 𝕜) 1) : @@ -105,7 +106,8 @@ instance Metric.unitClosedBall.instSemigroup [NonUnitalSeminormedRing 𝕜] : instance Metric.unitClosedBall.instHasDistribNeg [NonUnitalSeminormedRing 𝕜] : HasDistribNeg (closedBall (0 : 𝕜) 1) := - fast_instance% Subtype.coe_injective.hasDistribNeg ((↑) : closedBall (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl + fast_instance% Subtype.coe_injective.hasDistribNeg ((↑) : closedBall (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) + fun _ _ => rfl instance Metric.unitClosedBall.instContinuousMul [NonUnitalSeminormedRing 𝕜] : ContinuousMul (closedBall (0 : 𝕜) 1) := @@ -259,7 +261,8 @@ instance Metric.unitSphere.instGroup [NormedDivisionRing 𝕜] : Group (sphere ( instance Metric.sphere.instHasDistribNeg [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] : HasDistribNeg (sphere (0 : 𝕜) 1) := - fast_instance% Subtype.coe_injective.hasDistribNeg ((↑) : sphere (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) fun _ _ => rfl + fast_instance% Subtype.coe_injective.hasDistribNeg ((↑) : sphere (0 : 𝕜) 1 → 𝕜) (fun _ => rfl) + fun _ _ => rfl instance Metric.sphere.instContinuousMul [SeminormedRing 𝕜] [NormMulClass 𝕜] [NormOneClass 𝕜] : ContinuousMul (sphere (0 : 𝕜) 1) := diff --git a/Mathlib/Analysis/Normed/Group/SemiNormedGrp.lean b/Mathlib/Analysis/Normed/Group/SemiNormedGrp.lean index f6cf22f6659333..50811b503dfa71 100644 --- a/Mathlib/Analysis/Normed/Group/SemiNormedGrp.lean +++ b/Mathlib/Analysis/Normed/Group/SemiNormedGrp.lean @@ -202,7 +202,8 @@ theorem hom_zsum {V W : SemiNormedGrp} (n : ℤ) (f : V ⟶ W) : (n • f).hom = rfl instance Hom.addCommGroup {V W : SemiNormedGrp} : AddCommGroup (V ⟶ W) := - fast_instance% Function.Injective.addCommGroup _ ConcreteCategory.hom_injective rfl (fun _ _ => rfl) + fast_instance% Function.Injective.addCommGroup _ ConcreteCategory.hom_injective rfl + (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) end SemiNormedGrp diff --git a/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean b/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean index c29f1e3224cff4..ba625de50b6277 100644 --- a/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean +++ b/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean @@ -176,12 +176,14 @@ lemma neg_apply (f : IncidenceAlgebra 𝕜 α) (a b : α) : (-f) a b = -f a b := lemma sub_apply (f g : IncidenceAlgebra 𝕜 α) (a b : α) : (f - g) a b = f a b - g a b := rfl instance instAddGroup : AddGroup (IncidenceAlgebra 𝕜 α) := - fast_instance% DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ ↦ rfl) fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ ↦ rfl) + fun _ _ ↦ rfl end AddGroup instance instAddCommGroup [AddCommGroup 𝕜] [LE α] : AddCommGroup (IncidenceAlgebra 𝕜 α) := - fast_instance% DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ ↦ rfl) + fast_instance% DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub + (fun _ _ ↦ rfl) fun _ _ ↦ rfl section One @@ -278,12 +280,14 @@ instance [Preorder α] [LocallyFiniteOrder α] [DecidableEq α] [Semiring 𝕜] instance smulWithZeroRight [Zero 𝕜] [Zero 𝕝] [SMulWithZero 𝕜 𝕝] [LE α] : SMulWithZero 𝕜 (IncidenceAlgebra 𝕝 α) := - fast_instance% DFunLike.coe_injective.smulWithZero ⟨((⇑) : IncidenceAlgebra 𝕝 α → α → α → 𝕝), coe_zero⟩ + fast_instance% DFunLike.coe_injective.smulWithZero + ⟨((⇑) : IncidenceAlgebra 𝕝 α → α → α → 𝕝), coe_zero⟩ coe_constSMul instance moduleRight [Preorder α] [Semiring 𝕜] [AddCommMonoid 𝕝] [Module 𝕜 𝕝] : Module 𝕜 (IncidenceAlgebra 𝕝 α) := - fast_instance% DFunLike.coe_injective.module _ ⟨⟨((⇑) : IncidenceAlgebra 𝕝 α → α → α → 𝕝), coe_zero⟩, coe_add⟩ + fast_instance% DFunLike.coe_injective.module _ + ⟨⟨((⇑) : IncidenceAlgebra 𝕝 α → α → α → 𝕝), coe_zero⟩, coe_add⟩ coe_constSMul instance algebraRight [PartialOrder α] [LocallyFiniteOrder α] [DecidableEq α] [CommSemiring 𝕜] diff --git a/Mathlib/Combinatorics/SimpleGraph/Finsubgraph.lean b/Mathlib/Combinatorics/SimpleGraph/Finsubgraph.lean index 0fe5a31c7b717b..6d151749e35c1d 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Finsubgraph.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Finsubgraph.lean @@ -80,7 +80,8 @@ lemma coe_inf (G₁ G₂ : G.Finsubgraph) : ↑(G₁ ⊓ G₂) = (G₁ ⊓ G₂ lemma coe_sdiff (G₁ G₂ : G.Finsubgraph) : ↑(G₁ \ G₂) = (G₁ \ G₂ : G.Subgraph) := rfl instance instGeneralizedCoheytingAlgebra : GeneralizedCoheytingAlgebra G.Finsubgraph := - fast_instance% Subtype.coe_injective.generalizedCoheytingAlgebra _ .rfl .rfl coe_sup coe_inf coe_bot coe_sdiff + fast_instance% Subtype.coe_injective.generalizedCoheytingAlgebra _ .rfl .rfl coe_sup coe_inf + coe_bot coe_sdiff section Finite variable [Finite V] @@ -114,7 +115,8 @@ lemma coe_iInf {ι : Sort*} (f : ι → G.Finsubgraph) : ⨅ i, f i = (⨅ i, f rw [iInf, coe_sInf, iInf_range] instance instCompletelyDistribLattice : CompletelyDistribLattice G.Finsubgraph := - fast_instance% Subtype.coe_injective.completelyDistribLattice _ .rfl .rfl coe_sup coe_inf coe_sSup coe_sInf + fast_instance% Subtype.coe_injective.completelyDistribLattice _ .rfl .rfl coe_sup coe_inf coe_sSup + coe_sInf coe_top coe_bot coe_compl coe_himp coe_hnot coe_sdiff end Finite diff --git a/Mathlib/Combinatorics/Young/YoungDiagram.lean b/Mathlib/Combinatorics/Young/YoungDiagram.lean index 8e09a228be3077..215de3b7f08cf9 100644 --- a/Mathlib/Combinatorics/Young/YoungDiagram.lean +++ b/Mathlib/Combinatorics/Young/YoungDiagram.lean @@ -171,7 +171,8 @@ instance : Inhabited YoungDiagram := ⟨⊥⟩ instance : DistribLattice YoungDiagram := - fast_instance% Function.Injective.distribLattice YoungDiagram.cells (fun μ ν h ↦ by rwa [YoungDiagram.ext_iff]) + fast_instance% Function.Injective.distribLattice YoungDiagram.cells + (fun μ ν h ↦ by rwa [YoungDiagram.ext_iff]) .rfl .rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl end DistribLattice diff --git a/Mathlib/Data/DFinsupp/Defs.lean b/Mathlib/Data/DFinsupp/Defs.lean index 013ceb33e347ea..f9fbb0f3a847c6 100644 --- a/Mathlib/Data/DFinsupp/Defs.lean +++ b/Mathlib/Data/DFinsupp/Defs.lean @@ -267,11 +267,13 @@ theorem coe_zsmul [∀ i, AddGroup (β i)] (b : ℤ) (v : Π₀ i, β i) : ⇑(b rfl instance [∀ i, AddGroup (β i)] : AddGroup (Π₀ i, β i) := - fast_instance% DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _) + fast_instance% DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub + (fun _ _ => coe_nsmul _ _) fun _ _ => coe_zsmul _ _ instance addCommGroup [∀ i, AddCommGroup (β i)] : AddCommGroup (Π₀ i, β i) := - fast_instance% DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _) + fast_instance% DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub + (fun _ _ => coe_nsmul _ _) fun _ _ => coe_zsmul _ _ end Algebra diff --git a/Mathlib/Data/DFinsupp/Module.lean b/Mathlib/Data/DFinsupp/Module.lean index 5dd1417ce0eb9f..1bcdb7792982aa 100644 --- a/Mathlib/Data/DFinsupp/Module.lean +++ b/Mathlib/Data/DFinsupp/Module.lean @@ -62,7 +62,8 @@ instance isCentralScalar [∀ i, Zero (β i)] [∀ i, SMulZeroClass γ (β i)] structure on each coordinate. -/ instance distribMulAction [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] : DistribMulAction γ (Π₀ i, β i) := - fast_instance% Function.Injective.distribMulAction coeFnAddMonoidHom DFunLike.coe_injective coe_smul + fast_instance% Function.Injective.distribMulAction coeFnAddMonoidHom DFunLike.coe_injective + coe_smul /-- Dependent functions with finite support inherit a module structure from such a structure on each coordinate. -/ diff --git a/Mathlib/Data/Finsupp/Pointwise.lean b/Mathlib/Data/Finsupp/Pointwise.lean index d943ef734bf8d8..494a0671267ef5 100644 --- a/Mathlib/Data/Finsupp/Pointwise.lean +++ b/Mathlib/Data/Finsupp/Pointwise.lean @@ -75,20 +75,24 @@ instance [SemigroupWithZero β] : SemigroupWithZero (α →₀ β) := fast_instance% DFunLike.coe_injective.semigroupWithZero _ coe_zero coe_mul instance [NonUnitalNonAssocSemiring β] : NonUnitalNonAssocSemiring (α →₀ β) := - fast_instance% DFunLike.coe_injective.nonUnitalNonAssocSemiring _ coe_zero coe_add coe_mul fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.nonUnitalNonAssocSemiring _ coe_zero coe_add coe_mul + fun _ _ ↦ rfl instance [NonUnitalSemiring β] : NonUnitalSemiring (α →₀ β) := fast_instance% DFunLike.coe_injective.nonUnitalSemiring _ coe_zero coe_add coe_mul fun _ _ ↦ rfl instance [NonUnitalCommSemiring β] : NonUnitalCommSemiring (α →₀ β) := - fast_instance% DFunLike.coe_injective.nonUnitalCommSemiring _ coe_zero coe_add coe_mul fun _ _ ↦ rfl + fast_instance% DFunLike.coe_injective.nonUnitalCommSemiring _ coe_zero coe_add coe_mul + fun _ _ ↦ rfl instance [NonUnitalNonAssocRing β] : NonUnitalNonAssocRing (α →₀ β) := - fast_instance% DFunLike.coe_injective.nonUnitalNonAssocRing _ coe_zero coe_add coe_mul coe_neg coe_sub + fast_instance% DFunLike.coe_injective.nonUnitalNonAssocRing _ coe_zero coe_add coe_mul coe_neg + coe_sub (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance [NonUnitalRing β] : NonUnitalRing (α →₀ β) := - fast_instance% DFunLike.coe_injective.nonUnitalRing _ coe_zero coe_add coe_mul coe_neg coe_sub (fun _ _ ↦ rfl) + fast_instance% DFunLike.coe_injective.nonUnitalRing _ coe_zero coe_add coe_mul coe_neg coe_sub + (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance [NonUnitalCommRing β] : NonUnitalCommRing (α →₀ β) := diff --git a/Mathlib/Data/Fintype/Sigma.lean b/Mathlib/Data/Fintype/Sigma.lean index f1fee898bc5037..d74706be1e1729 100644 --- a/Mathlib/Data/Fintype/Sigma.lean +++ b/Mathlib/Data/Fintype/Sigma.lean @@ -41,6 +41,7 @@ lemma Set.biInter_finsetSigma_univ' (s : Finset ι) (f : Π i, κ i → Set α) variable [Fintype ι] instance Sigma.instFintype : Fintype (Σ i, κ i) := ⟨univ.sigma fun _ ↦ univ, by simp⟩ -instance PSigma.instFintype : Fintype (Σ' i, κ i) := fast_instance% .ofEquiv _ (Equiv.psigmaEquivSigma _).symm +instance PSigma.instFintype : Fintype (Σ' i, κ i) := fast_instance% + .ofEquiv _ (Equiv.psigmaEquivSigma _).symm @[simp] lemma Finset.univ_sigma_univ : univ.sigma (fun _ ↦ univ) = (univ : Finset (Σ i, κ i)) := rfl diff --git a/Mathlib/Geometry/Diffeology/Basic.lean b/Mathlib/Geometry/Diffeology/Basic.lean index 1a3c0dbdd55654..03fb612080aa95 100644 --- a/Mathlib/Geometry/Diffeology/Basic.lean +++ b/Mathlib/Geometry/Diffeology/Basic.lean @@ -495,7 +495,8 @@ lemma isPlot_generatedFrom_of_mem {g : Set ((n : ℕ) × (𝔼ⁿ → X))} {n : (hp : ⟨n, p⟩ ∈ g) : (@IsPlot _ (generateFrom g)) p := self_subset_toPlots_generateFrom g hp -instance : PartialOrder (DiffeologicalSpace X) := fast_instance% PartialOrder.lift _ injective_toPlots +instance : PartialOrder (DiffeologicalSpace X) := fast_instance% + PartialOrder.lift _ injective_toPlots lemma le_def {d₁ d₂ : DiffeologicalSpace X} : d₁ ≤ d₂ ↔ d₁.toPlots ⊆ d₂.toPlots := Iff.rfl diff --git a/Mathlib/GroupTheory/GroupAction/SubMulAction.lean b/Mathlib/GroupTheory/GroupAction/SubMulAction.lean index 13401b201ff73d..8de408db39eaf2 100644 --- a/Mathlib/GroupTheory/GroupAction/SubMulAction.lean +++ b/Mathlib/GroupTheory/GroupAction/SubMulAction.lean @@ -271,7 +271,8 @@ instance : InfSet (SubMulAction R M) := @[to_additive] instance : CompleteLattice (SubMulAction R M) := - fast_instance% SetLike.coe_injective.completeLattice _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + fast_instance% SetLike.coe_injective.completeLattice _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ ↦ rfl) (fun _ ↦ rfl) rfl rfl @[to_additive (attr := simp)] diff --git a/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean b/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean index 0faea6e474555a..0bd980fb719d5e 100644 --- a/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean +++ b/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean @@ -458,7 +458,8 @@ theorem add_apply (Q Q' : QuadraticMap R M N) (x : M) : (Q + Q') x = Q x + Q' x rfl instance : AddCommMonoid (QuadraticMap R M N) := - fast_instance% DFunLike.coe_injective.addCommMonoid _ coeFn_zero coeFn_add fun _ _ => coeFn_smul _ _ + fast_instance% DFunLike.coe_injective.addCommMonoid _ coeFn_zero coeFn_add + fun _ _ => coeFn_smul _ _ /-- `@CoeFn (QuadraticMap R M)` as an `AddMonoidHom`. diff --git a/Mathlib/Logic/Encodable/Pi.lean b/Mathlib/Logic/Encodable/Pi.lean index 7923ccc0bf3294..11a4bf954d612b 100644 --- a/Mathlib/Logic/Encodable/Pi.lean +++ b/Mathlib/Logic/Encodable/Pi.lean @@ -64,6 +64,7 @@ def fintypePi (α : Type*) (π : α → Type*) [DecidableEq α] [Fintype α] [ /-- If `α` and `β` are encodable and `α` is a fintype, then `α → β` is encodable as well. -/ instance fintypeArrowOfEncodable {α β : Type*} [Encodable α] [Fintype α] [Encodable β] : Encodable (α → β) := - fast_instance% ofEquiv (Fin (Fintype.card α) → β) <| Equiv.arrowCongr fintypeEquivFin (Equiv.refl _) + fast_instance% ofEquiv (Fin (Fintype.card α) → β) <| Equiv.arrowCongr fintypeEquivFin + (Equiv.refl _) end Encodable diff --git a/Mathlib/MeasureTheory/Function/SimpleFunc.lean b/Mathlib/MeasureTheory/Function/SimpleFunc.lean index 9e94bc5c965330..c65a20dec1f9d8 100644 --- a/Mathlib/MeasureTheory/Function/SimpleFunc.lean +++ b/Mathlib/MeasureTheory/Function/SimpleFunc.lean @@ -514,7 +514,8 @@ instance instAddCommMonoid [AddCommMonoid β] : AddCommMonoid (α →ₛ β) := coe_injective coe_zero coe_add fun _ _ => coe_smul _ _ instance instAddGroup [AddGroup β] : AddGroup (α →ₛ β) := - fast_instance% Function.Injective.addGroup (fun f => show α → β from f) coe_injective coe_zero coe_add coe_neg + fast_instance% Function.Injective.addGroup + (fun f => show α → β from f) coe_injective coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _ instance instAddCommGroup [AddCommGroup β] : AddCommGroup (α →ₛ β) := diff --git a/Mathlib/MeasureTheory/MeasurableSpace/MeasurablyGenerated.lean b/Mathlib/MeasureTheory/MeasurableSpace/MeasurablyGenerated.lean index 1eb3da1f7992b7..cf6c929b3bdc98 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/MeasurablyGenerated.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/MeasurablyGenerated.lean @@ -283,7 +283,8 @@ theorem coe_top : ↑(⊤ : Subtype (MeasurableSet : Set α → Prop)) = (⊤ : noncomputable instance Subtype.instBooleanAlgebra : BooleanAlgebra (Subtype (MeasurableSet : Set α → Prop)) := - fast_instance% Subtype.coe_injective.booleanAlgebra _ .rfl .rfl coe_union coe_inter coe_top coe_bot coe_compl + fast_instance% Subtype.coe_injective.booleanAlgebra _ .rfl .rfl coe_union coe_inter coe_top + coe_bot coe_compl coe_sdiff coe_himp @[measurability] diff --git a/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean b/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean index cd3e4c472f3a64..00e73205a2489e 100644 --- a/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean +++ b/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean @@ -275,7 +275,8 @@ theorem toMeasure_sum {ι : Type*} {s : Finset ι} {ν : ι → FiniteMeasure Ω map_sum toMeasureAddMonoidHom _ _ instance {Ω : Type*} [MeasurableSpace Ω] : Module ℝ≥0 (FiniteMeasure Ω) := - fast_instance% Function.Injective.module _ toMeasureAddMonoidHom toMeasure_injective toMeasure_smul + fast_instance% Function.Injective.module _ toMeasureAddMonoidHom toMeasure_injective + toMeasure_smul @[simp] theorem smul_apply [IsScalarTower R ℝ≥0 ℝ≥0] (c : R) (μ : FiniteMeasure Ω) (s : Set Ω) : diff --git a/Mathlib/MeasureTheory/VectorMeasure/Basic.lean b/Mathlib/MeasureTheory/VectorMeasure/Basic.lean index 5cf107fa45a90c..31bb5f5ceeae37 100644 --- a/Mathlib/MeasureTheory/VectorMeasure/Basic.lean +++ b/Mathlib/MeasureTheory/VectorMeasure/Basic.lean @@ -305,7 +305,8 @@ theorem coe_add (v w : VectorMeasure α M) : ⇑(v + w) = v + w := rfl theorem add_apply (v w : VectorMeasure α M) (i : Set α) : (v + w) i = v i + w i := rfl instance instAddCommMonoid : AddCommMonoid (VectorMeasure α M) := - fast_instance% Function.Injective.addCommMonoid _ coe_injective coe_zero coe_add fun _ _ => coe_smul _ _ + fast_instance% Function.Injective.addCommMonoid _ coe_injective coe_zero coe_add + fun _ _ => coe_smul _ _ /-- `(⇑)` is an `AddMonoidHom`. -/ @[simps] diff --git a/Mathlib/NumberTheory/ModularForms/SlashInvariantForms.lean b/Mathlib/NumberTheory/ModularForms/SlashInvariantForms.lean index 219284d9ccb866..746591c050ad4a 100644 --- a/Mathlib/NumberTheory/ModularForms/SlashInvariantForms.lean +++ b/Mathlib/NumberTheory/ModularForms/SlashInvariantForms.lean @@ -203,7 +203,8 @@ theorem sub_apply (f g : SlashInvariantForm Γ k) (z : ℍ) : (f - g) z = f z - rfl instance : AddCommGroup (SlashInvariantForm Γ k) := - fast_instance% DFunLike.coe_injective.addCommGroup _ rfl coe_add coe_neg coe_sub coe_smulℝ coe_smulℝ + fast_instance% DFunLike.coe_injective.addCommGroup _ rfl coe_add coe_neg coe_sub coe_smulℝ + coe_smulℝ /-- Additive coercion from `SlashInvariantForm` to `ℍ → ℂ`. -/ def coeHom : SlashInvariantForm Γ k →+ ℍ → ℂ where diff --git a/Mathlib/Order/UpperLower/CompleteLattice.lean b/Mathlib/Order/UpperLower/CompleteLattice.lean index ddb78d09bf25ef..7ddd56ebc9c811 100644 --- a/Mathlib/Order/UpperLower/CompleteLattice.lean +++ b/Mathlib/Order/UpperLower/CompleteLattice.lean @@ -111,7 +111,8 @@ instance _root_.LowerSet.completeLattice : CompleteLattice (LowerSet α) := @[to_dual existing] instance _root_.LowerSet.completelyDistribLattice : CompletelyDistribLattice (LowerSet α) := - fast_instance% .ofMinimalAxioms <| SetLike.coe_injective.completelyDistribLatticeMinimalAxioms .of _ + fast_instance% .ofMinimalAxioms <| SetLike.coe_injective.completelyDistribLatticeMinimalAxioms .of + _ .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) rfl rfl @[to_dual] diff --git a/Mathlib/RingTheory/FractionalIdeal/Basic.lean b/Mathlib/RingTheory/FractionalIdeal/Basic.lean index 0d2af43de4d351..2a1ee132251518 100644 --- a/Mathlib/RingTheory/FractionalIdeal/Basic.lean +++ b/Mathlib/RingTheory/FractionalIdeal/Basic.lean @@ -606,7 +606,8 @@ theorem coe_natCast (n : ℕ) : ((n : FractionalIdeal S P) : Submodule R P) = n by induction n <;> simp [*, Nat.unaryCast] instance commSemiring : CommSemiring (FractionalIdeal S P) := - fast_instance% Function.Injective.commSemiring _ Subtype.coe_injective coe_zero coe_one coe_add coe_mul + fast_instance% Function.Injective.commSemiring _ Subtype.coe_injective coe_zero coe_one coe_add + coe_mul (fun _ _ => coe_nsmul _ _) coe_pow coe_natCast instance : CanonicallyOrderedAdd (FractionalIdeal S P) where diff --git a/Mathlib/Topology/Algebra/ContinuousAffineMap.lean b/Mathlib/Topology/Algebra/ContinuousAffineMap.lean index 50b4c372d27b23..0e7917e9cde5fc 100644 --- a/Mathlib/Topology/Algebra/ContinuousAffineMap.lean +++ b/Mathlib/Topology/Algebra/ContinuousAffineMap.lean @@ -312,12 +312,14 @@ instance : AddCommGroup (P →ᴬ[R] W) := instance [Monoid S] [DistribMulAction S W] [SMulCommClass R S W] [ContinuousConstSMul S W] : DistribMulAction S (P →ᴬ[R] W) := - fast_instance% Function.Injective.distribMulAction ⟨⟨fun f ↦ f.toAffineMap.toFun, rfl⟩, coe_add⟩ coe_injective + fast_instance% Function.Injective.distribMulAction + ⟨⟨fun f ↦ f.toAffineMap.toFun, rfl⟩, coe_add⟩ coe_injective coe_smul instance [Semiring S] [Module S W] [SMulCommClass R S W] [ContinuousConstSMul S W] : Module S (P →ᴬ[R] W) := - fast_instance% Function.Injective.module S ⟨⟨fun f ↦ f.toAffineMap.toFun, rfl⟩, coe_add⟩ coe_injective coe_smul + fast_instance% Function.Injective.module S + ⟨⟨fun f ↦ f.toAffineMap.toFun, rfl⟩, coe_add⟩ coe_injective coe_smul variable [TopologicalSpace V] [IsTopologicalAddTorsor P] diff --git a/Mathlib/Topology/Algebra/RestrictedProduct/Basic.lean b/Mathlib/Topology/Algebra/RestrictedProduct/Basic.lean index 82fbd288f77d6a..bea13a0418a24e 100644 --- a/Mathlib/Topology/Algebra/RestrictedProduct/Basic.lean +++ b/Mathlib/Topology/Algebra/RestrictedProduct/Basic.lean @@ -284,7 +284,8 @@ instance [Π i, Group (R i)] [∀ i, SubgroupClass (S i) (R i)] : @[to_additive] instance [Π i, CommGroup (R i)] [∀ i, SubgroupClass (S i) (R i)] : CommGroup (Πʳ i, [R i, B i]_[𝓕]) := - fast_instance% DFunLike.coe_injective.commGroup _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + fast_instance% DFunLike.coe_injective.commGroup _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) instance [Π i, Ring (R i)] [∀ i, SubringClass (S i) (R i)] : diff --git a/Mathlib/Topology/LocallyConstant/Algebra.lean b/Mathlib/Topology/LocallyConstant/Algebra.lean index 6f96a4ac7ecbdb..49e23b2cb36f9b 100644 --- a/Mathlib/Topology/LocallyConstant/Algebra.lean +++ b/Mathlib/Topology/LocallyConstant/Algebra.lean @@ -60,7 +60,8 @@ theorem mul_apply [Mul Y] (f g : LocallyConstant X Y) (x : X) : (f * g) x = f x @[to_additive] instance [MulOneClass Y] : MulOneClass (LocallyConstant X Y) := - fast_instance% Function.Injective.mulOneClass DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl + fast_instance% Function.Injective.mulOneClass DFunLike.coe DFunLike.coe_injective' rfl + fun _ _ => rfl /-- `DFunLike.coe` as a `MonoidHom`. -/ @[to_additive (attr := simps) /-- `DFunLike.coe` as an `AddMonoidHom`. -/] @@ -77,10 +78,12 @@ def constMonoidHom [MulOneClass Y] : Y →* LocallyConstant X Y where map_mul' _ _ := rfl instance [MulZeroClass Y] : MulZeroClass (LocallyConstant X Y) := - fast_instance% Function.Injective.mulZeroClass DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl + fast_instance% Function.Injective.mulZeroClass DFunLike.coe DFunLike.coe_injective' rfl + fun _ _ => rfl instance [MulZeroOneClass Y] : MulZeroOneClass (LocallyConstant X Y) := - fast_instance% Function.Injective.mulZeroOneClass DFunLike.coe DFunLike.coe_injective' rfl rfl fun _ _ => rfl + fast_instance% Function.Injective.mulZeroOneClass DFunLike.coe DFunLike.coe_injective' rfl rfl + fun _ _ => rfl section CharFn @@ -123,11 +126,13 @@ instance [Semigroup Y] : Semigroup (LocallyConstant X Y) := fast_instance% Function.Injective.semigroup DFunLike.coe DFunLike.coe_injective' fun _ _ => rfl instance [SemigroupWithZero Y] : SemigroupWithZero (LocallyConstant X Y) := - fast_instance% Function.Injective.semigroupWithZero DFunLike.coe DFunLike.coe_injective' rfl fun _ _ => rfl + fast_instance% Function.Injective.semigroupWithZero DFunLike.coe DFunLike.coe_injective' rfl + fun _ _ => rfl @[to_additive] instance [CommSemigroup Y] : CommSemigroup (LocallyConstant X Y) := - fast_instance% Function.Injective.commSemigroup DFunLike.coe DFunLike.coe_injective' fun _ _ => rfl + fast_instance% Function.Injective.commSemigroup DFunLike.coe DFunLike.coe_injective' + fun _ _ => rfl variable {α R : Type*} @@ -149,7 +154,8 @@ instance [Pow Y α] : Pow (LocallyConstant X Y) α where @[to_additive] instance [Monoid Y] : Monoid (LocallyConstant X Y) := - fast_instance% Function.Injective.monoid DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Function.Injective.monoid DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fun _ _ => rfl instance [NatCast Y] : NatCast (LocallyConstant X Y) where natCast n := const X n @@ -158,12 +164,14 @@ instance [IntCast Y] : IntCast (LocallyConstant X Y) where intCast n := const X n instance [AddMonoidWithOne Y] : AddMonoidWithOne (LocallyConstant X Y) := - fast_instance% Function.Injective.addMonoidWithOne DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) + fast_instance% Function.Injective.addMonoidWithOne DFunLike.coe DFunLike.coe_injective' rfl rfl + (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl @[to_additive] instance [CommMonoid Y] : CommMonoid (LocallyConstant X Y) := - fast_instance% Function.Injective.commMonoid DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.commMonoid DFunLike.coe DFunLike.coe_injective' rfl + (fun _ _ => rfl) fun _ _ => rfl @[to_additive] @@ -173,14 +181,17 @@ instance [Group Y] : Group (LocallyConstant X Y) := @[to_additive] instance [CommGroup Y] : CommGroup (LocallyConstant X Y) := - fast_instance% Function.Injective.commGroup DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.commGroup DFunLike.coe DFunLike.coe_injective' rfl + (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [Distrib Y] : Distrib (LocallyConstant X Y) := - fast_instance% Function.Injective.distrib DFunLike.coe DFunLike.coe_injective' (fun _ _ => rfl) fun _ _ => rfl + fast_instance% Function.Injective.distrib DFunLike.coe DFunLike.coe_injective' (fun _ _ => rfl) + fun _ _ => rfl instance [NonUnitalNonAssocSemiring Y] : NonUnitalNonAssocSemiring (LocallyConstant X Y) := - fast_instance% Function.Injective.nonUnitalNonAssocSemiring DFunLike.coe DFunLike.coe_injective' rfl + fast_instance% Function.Injective.nonUnitalNonAssocSemiring DFunLike.coe DFunLike.coe_injective' + rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonUnitalSemiring Y] : NonUnitalSemiring (LocallyConstant X Y) := @@ -209,29 +220,35 @@ instance [CommSemiring Y] : CommSemiring (LocallyConstant X Y) := (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl instance [NonUnitalNonAssocRing Y] : NonUnitalNonAssocRing (LocallyConstant X Y) := - fast_instance% Function.Injective.nonUnitalNonAssocRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.nonUnitalNonAssocRing DFunLike.coe DFunLike.coe_injective' rfl + (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonUnitalRing Y] : NonUnitalRing (LocallyConstant X Y) := - fast_instance% Function.Injective.nonUnitalRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.nonUnitalRing DFunLike.coe DFunLike.coe_injective' rfl + (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [NonAssocRing Y] : NonAssocRing (LocallyConstant X Y) := - fast_instance% Function.Injective.nonAssocRing DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) + fast_instance% Function.Injective.nonAssocRing DFunLike.coe DFunLike.coe_injective' rfl rfl + (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ => rfl) instance [Ring Y] : Ring (LocallyConstant X Y) := - fast_instance% Function.Injective.ring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) + fast_instance% Function.Injective.ring DFunLike.coe DFunLike.coe_injective' rfl rfl + (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) fun _ => rfl instance [NonUnitalCommRing Y] : NonUnitalCommRing (LocallyConstant X Y) := - fast_instance% Function.Injective.nonUnitalCommRing DFunLike.coe DFunLike.coe_injective' rfl (fun _ _ => rfl) + fast_instance% Function.Injective.nonUnitalCommRing DFunLike.coe DFunLike.coe_injective' rfl + (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) instance [CommRing Y] : CommRing (LocallyConstant X Y) := - fast_instance% Function.Injective.commRing DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) + fast_instance% Function.Injective.commRing DFunLike.coe DFunLike.coe_injective' rfl rfl + (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) fun _ => rfl From d857bd426fd9a0d33ddc47becb7cd340ca6b3bba Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 01:22:20 +0200 Subject: [PATCH 10/30] fix --- Mathlib/RingTheory/Ideal/Over.lean | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Mathlib/RingTheory/Ideal/Over.lean b/Mathlib/RingTheory/Ideal/Over.lean index b43cff05fb39b6..376c113a794823 100644 --- a/Mathlib/RingTheory/Ideal/Over.lean +++ b/Mathlib/RingTheory/Ideal/Over.lean @@ -339,7 +339,11 @@ def stabilizerHom : MulAction.stabilizer G P →* ((B ⧸ P) ≃ₐ[A ⧸ p] (B lemma ker_stabilizerHom : (stabilizerHom P p G).ker = (P.inertia G).subgroupOf _ := by ext σ - simp [DFunLike.ext_iff, mk_surjective.forall, Quotient.eq] + refine ⟨fun h x ↦ Ideal.Quotient.eq.mp (DFunLike.congr_fun h (Ideal.Quotient.mk P x)), + fun h ↦ ?_⟩ + ext q + obtain ⟨x, rfl⟩ := mk_surjective q + exact Ideal.Quotient.eq.mpr (h x) theorem map_ker_stabilizer_subtype : (stabilizerHom P p G).ker.map (Subgroup.subtype _) = P.inertia G := by From 340edf5e480f87a61f0cc24b4683dd30c82eb9b1 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 01:24:05 +0200 Subject: [PATCH 11/30] fix --- Mathlib/Algebra/MonoidAlgebra/Basic.lean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mathlib/Algebra/MonoidAlgebra/Basic.lean b/Mathlib/Algebra/MonoidAlgebra/Basic.lean index beafcef436f651..917972b0a09025 100644 --- a/Mathlib/Algebra/MonoidAlgebra/Basic.lean +++ b/Mathlib/Algebra/MonoidAlgebra/Basic.lean @@ -314,7 +314,7 @@ theorem domCongr_toAlgHom (e : M ≃* N) : (domCongr R A e).toAlgHom = mapDomain @[to_additive (attr := simp)] lemma domCongr_support (e : M ≃* N) (f : A[M]) : (domCongr R A e f).support = f.support.map e := by - ext; simp + ext; simp [MulEquiv.apply_eq_iff_symm_apply] @[to_additive (attr := simp)] theorem domCongr_single (e : M ≃* N) (m : M) (a : A) : From ad71a435f8bb922bbefa2a034fc973c198a88d4b Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 01:33:29 +0200 Subject: [PATCH 12/30] fix --- Mathlib/RingTheory/TensorProduct/Quotient.lean | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Mathlib/RingTheory/TensorProduct/Quotient.lean b/Mathlib/RingTheory/TensorProduct/Quotient.lean index f12cad92295d8e..b3449066019b68 100644 --- a/Mathlib/RingTheory/TensorProduct/Quotient.lean +++ b/Mathlib/RingTheory/TensorProduct/Quotient.lean @@ -44,7 +44,7 @@ noncomputable def quotIdealMapEquivTensorQuotAux : rfl private lemma quotIdealMapEquivTensorQuotAux_mk (b : B) : - (quotIdealMapEquivTensorQuotAux B I) b = b ⊗ₜ[A] 1 := + (quotIdealMapEquivTensorQuotAux B I) (Ideal.Quotient.mk _ b) = b ⊗ₜ[A] 1 := rfl /-- `B ⊗[A] (A ⧸ I)` is isomorphic as a `B`-algebra to `B ⧸ I B`. -/ @@ -59,12 +59,13 @@ noncomputable def quotIdealMapEquivTensorQuot : @[simp] lemma quotIdealMapEquivTensorQuot_mk (b : B) : - quotIdealMapEquivTensorQuot B I b = b ⊗ₜ[A] 1 := + quotIdealMapEquivTensorQuot B I (Ideal.Quotient.mk _ b) = b ⊗ₜ[A] 1 := rfl @[simp] lemma quotIdealMapEquivTensorQuot_symm_tmul (b : B) (a : A) : - (quotIdealMapEquivTensorQuot B I).symm (b ⊗ₜ[A] a) = Submodule.Quotient.mk (a • b) := + (quotIdealMapEquivTensorQuot B I).symm (b ⊗ₜ[A] Ideal.Quotient.mk _ a) = + Ideal.Quotient.mk _ (a • b) := rfl /-- `(A ⧸ I) ⊗[A] B` is isomorphic as an `A ⧸ I`-algebra to `B ⧸ I B`. -/ @@ -82,7 +83,7 @@ noncomputable def quotIdealMapEquivQuotTensor : @[simp] lemma quotIdealMapEquivQuotTensor_mk (b : B) : - quotIdealMapEquivQuotTensor B I b = 1 ⊗ₜ[A] b := + quotIdealMapEquivQuotTensor B I (Ideal.Quotient.mk _ b) = 1 ⊗ₜ[A] b := rfl end From 76c759b5d30f545234eea6227b6d0999a7129a7f Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 01:34:44 +0200 Subject: [PATCH 13/30] another one --- Mathlib/RingTheory/Polynomial/Quotient.lean | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mathlib/RingTheory/Polynomial/Quotient.lean b/Mathlib/RingTheory/Polynomial/Quotient.lean index 97d50f2adca109..af2266701154f9 100644 --- a/Mathlib/RingTheory/Polynomial/Quotient.lean +++ b/Mathlib/RingTheory/Polynomial/Quotient.lean @@ -66,7 +66,8 @@ noncomputable def quotientSpanCXSubCXSubCAlgEquiv {x : R} {y : R[X]} : lemma modByMonic_eq_zero_iff_quotient_eq_zero (p q : R[X]) (hq : q.Monic) : p %ₘ q = 0 ↔ (p : R[X] ⧸ Ideal.span {q}) = 0 := by - rw [modByMonic_eq_zero_iff_dvd hq, Ideal.Quotient.eq_zero_iff_dvd] + rw [modByMonic_eq_zero_iff_dvd hq] + exact (Ideal.Quotient.eq_zero_iff_dvd q p).symm end Polynomial From f6a6609f102851c8f816b046bdf14c78a833e8da Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 01:38:34 +0200 Subject: [PATCH 14/30] fix --- Mathlib/RingTheory/MvPowerSeries/Equiv.lean | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mathlib/RingTheory/MvPowerSeries/Equiv.lean b/Mathlib/RingTheory/MvPowerSeries/Equiv.lean index b5bc70584d0f87..a2391352b7c7bc 100644 --- a/Mathlib/RingTheory/MvPowerSeries/Equiv.lean +++ b/Mathlib/RingTheory/MvPowerSeries/Equiv.lean @@ -54,7 +54,7 @@ the ideal spanned by all variables. -/ def truncTotalAlgHom (σ R : Type*) [Finite σ] [CommRing R] (n : ℕ) : MvPowerSeries σ R →ₐ[MvPolynomial σ R] MvPolynomial σ R ⧸ (MvPolynomial.idealOfVars σ R) ^ n where - toFun p := truncTotal n p + toFun p := Ideal.Quotient.mk _ (truncTotal n p) map_one' := by by_cases! h : n = 0 · have := Ideal.Quotient.subsingleton_iff.mpr @@ -95,6 +95,7 @@ theorem coeff_toAdicCompletion_val_apply_out {x : σ →₀ ℕ} {p : MvPowerSer · rw [toAdicCompletion_apply_eq_mk_truncTotal, smul_eq_mul] nth_rw 1 [← Ideal.mul_top (MvPolynomial.idealOfVars σ R ^ n), ← Ideal.Quotient.eq, Ideal.Quotient.mk_out] + rfl exact hx theorem toAdicCompletion_coe (p : MvPolynomial σ R) : From b39823bb69f5b7eefd0521b396a9a022ea0df283 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 01:41:50 +0200 Subject: [PATCH 15/30] another one --- Mathlib/RingTheory/Extension/Generators.lean | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mathlib/RingTheory/Extension/Generators.lean b/Mathlib/RingTheory/Extension/Generators.lean index 25e43405b706bc..ebe59e795dcccf 100644 --- a/Mathlib/RingTheory/Extension/Generators.lean +++ b/Mathlib/RingTheory/Extension/Generators.lean @@ -651,7 +651,8 @@ lemma map_toComp_ker (Q : Generators S T ι') (P : Generators R S ι) : suffices ∑ v ∈ (support x).map e, (monomial (e.symm v)) (coeff (e.symm v) x) ∈ Ideal.map (Q.toComp P).toAlgHom.toRingHom P.ker by simpa only [AlgHom.toRingHom_eq_coe, Finset.sum_map, Equiv.coe_toEmbedding, - EquivLike.coe_coe, AddEquiv.symm_apply_apply, support_sum_monomial_coeff] using this + EquivLike.coe_coe, AddEquiv.symm_apply_apply, support_sum_monomial_coeff, + Function.Embedding.coeFn_mk] using this rw [← Finset.sum_fiberwise_of_maps_to (fun i ↦ Finset.mem_image_of_mem Prod.fst)] refine sum_mem fun i hi ↦ ?_ convert_to monomial (e.symm (i, 0)) 1 * (Q.toComp P).toAlgHom.toRingHom From 833f25123471644bf6ae17a89ad638464b377668 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 01:48:02 +0200 Subject: [PATCH 16/30] again --- Mathlib/Geometry/Euclidean/Incenter.lean | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Mathlib/Geometry/Euclidean/Incenter.lean b/Mathlib/Geometry/Euclidean/Incenter.lean index 2d2c443c690725..eddfa658605167 100644 --- a/Mathlib/Geometry/Euclidean/Incenter.lean +++ b/Mathlib/Geometry/Euclidean/Incenter.lean @@ -1122,8 +1122,10 @@ lemma touchpointWeights_reindex (e : Fin (n + 1) ≃ Fin (m + 1)) (signs : Finse rw [eq_comm, ← affineCombination_eq_touchpoint_iff] · rw [touchpoint_reindex, ← affineCombination_touchpointWeights, reindex] dsimp only - rw [← Equiv.coe_toEmbedding, ← Finset.affineCombination_map] - simp + let e' : Fin (m + 1) ↪ Fin (n + 1) := e.symm.toEmbedding + change (Finset.affineCombination ℝ Finset.univ (_ ∘ e')) (s.touchpointWeights _ _ ∘ e') = _ + rw [← Finset.affineCombination_map] + simp [e'] · rw [Finset.sum_comp_equiv] simp From f28ec51a2023426112a47f8e0584efc254051169 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 02:10:10 +0200 Subject: [PATCH 17/30] fix --- Mathlib/NumberTheory/KummerDedekind.lean | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Mathlib/NumberTheory/KummerDedekind.lean b/Mathlib/NumberTheory/KummerDedekind.lean index e5a45bb93d2bd9..a70d8c9c4f8fd7 100644 --- a/Mathlib/NumberTheory/KummerDedekind.lean +++ b/Mathlib/NumberTheory/KummerDedekind.lean @@ -86,10 +86,14 @@ noncomputable def quotMapEquivQuotQuotMap (hx : (conductor R x).comap (algebraMa lemma quotMapEquivQuotQuotMap_symm_apply (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x) (Q : R[X]) : (quotMapEquivQuotQuotMap hx hx').symm (Q.map (Ideal.Quotient.mk I)) = Q.aeval x := by + change (quotMapEquivQuotQuotMap hx hx').symm (Q.map (Ideal.Quotient.mk I)) = + Ideal.Quotient.mk (I.map (algebraMap R S)) (Q.aeval x) apply (quotMapEquivQuotQuotMap hx hx').injective rw [quotMapEquivQuotQuotMap, RingEquiv.symm_trans_apply, RingEquiv.symm_symm, RingEquiv.coe_trans, Function.comp_apply, RingEquiv.symm_apply_apply, - RingEquiv.symm_trans_apply, quotEquivOfEq_symm, quotEquivOfEq_mk] + RingEquiv.symm_trans_apply, quotEquivOfEq_symm] + simp only [OneHom.toFun_eq_coe] + rw (transparency := .default) [quotEquivOfEq_mk] congr convert! (adjoin.powerBasis' hx').quotientEquivQuotientMinpolyMap_symm_apply_mk I Q apply (quotAdjoinEquivQuotMap hx @@ -222,13 +226,22 @@ theorem normalizedFactorsMapEquivNormalizedFactorsMinPolyMk_symm_apply_eq_span rw [IsDedekindDomain.normalizedFactorsEquivOfQuotEquiv_symm] dsimp [IsDedekindDomain.normalizedFactorsEquivOfQuotEquiv, IsDedekindDomain.idealFactorsEquivOfQuotEquiv, OrderIso.ofHomInv] - simp only [map_span, image_singleton, coe_coe, quotMapEquivQuotQuotMap_symm_apply hx hx' Q] + have hquot : + (quotMapEquivQuotQuotMap hx hx').symm + (Ideal.Quotient.mk (span {Polynomial.map (Ideal.Quotient.mk I) (minpoly R x)}) + (Polynomial.map (Ideal.Quotient.mk I) Q)) = + Ideal.Quotient.mk (I.map (algebraMap R S)) (Polynomial.aeval x Q) := by + simpa using quotMapEquivQuotQuotMap_symm_apply hx hx' Q + simp only [map_span, image_singleton, coe_coe] + rw [hquot] refine le_antisymm (fun a ha ↦ ?_) (span_le.mpr <| union_subset_iff.mpr <| ⟨le_comap_of_map_le (by simp), by simp⟩) rw [mem_comap, Ideal.mem_span_singleton] at ha obtain ⟨a', ha'⟩ := ha obtain ⟨b, hb⟩ := Ideal.Quotient.mk_surjective a' - rw [← hb, ← map_mul, Quotient.mk_eq_mk_iff_sub_mem] at ha' + rw [← hb] at ha' + rw [← (Ideal.Quotient.mk (I.map (algebraMap R S))).map_mul, + Quotient.mk_eq_mk_iff_sub_mem] at ha' rw [union_comm, span_union, span_eq, mem_span_singleton_sup] exact ⟨b, a - Q.aeval x * b, ha', by ring⟩ From 2129ff6897925f514aee2f79e86656040a2fa0a8 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 02:17:27 +0200 Subject: [PATCH 18/30] another one --- .../Finiteness/FinitePresentationLocal.lean | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Mathlib/RingTheory/Finiteness/FinitePresentationLocal.lean b/Mathlib/RingTheory/Finiteness/FinitePresentationLocal.lean index 0b759d65bcc3dc..4415163545f933 100644 --- a/Mathlib/RingTheory/Finiteness/FinitePresentationLocal.lean +++ b/Mathlib/RingTheory/Finiteness/FinitePresentationLocal.lean @@ -98,12 +98,16 @@ lemma of_span_eq_top_target (s : Set S) (hs : Ideal.span (s : Set S) = ⊤) have ht : Ideal.span (t : Set A) = ⊤ := by rw [Ideal.eq_top_iff_one] have : ∑ g : { x // x ∈ s }, g' g * h' g = (1 : A) := by - apply eq_of_sub_eq_zero - rw [← map_one (Ideal.Quotient.mk I), ← map_sub, Ideal.Quotient.eq_zero_iff_mem] - apply Ideal.subset_span - simp - simp_rw [← this, Finset.univ_eq_attach, map_sum, map_mul] - refine Ideal.sum_mem _ (fun g _ ↦ Ideal.mul_mem_right _ _ <| Ideal.subset_span ?_) + exact (Ideal.Quotient.mk_eq_one_iff_sub_mem (I := I) _).mpr <| Ideal.subset_span <| by + simp + rw [← this, Finset.univ_eq_attach] + suffices (Ideal.Quotient.mk I) (∑ g ∈ s.attach, g' g * h' g) ∈ + Ideal.span (t : Set A) by + exact this + rw [map_sum] + simp_rw [(Ideal.Quotient.mk I).map_mul] + refine Ideal.sum_mem _ (fun g _ ↦ Ideal.mul_mem_right ((Ideal.Quotient.mk I) (h' g)) + (Ideal.span (t : Set A)) <| Ideal.subset_span ?_) simp [t] have : Algebra.FinitePresentation R A := by apply Algebra.FinitePresentation.quotient From a761a3066071ebc2464d177ab27282f5193c5bea Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 02:19:26 +0200 Subject: [PATCH 19/30] also this --- Mathlib/RingTheory/MvPolynomial/Localization.lean | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Mathlib/RingTheory/MvPolynomial/Localization.lean b/Mathlib/RingTheory/MvPolynomial/Localization.lean index 77863f30d613c6..1baa2dd89679dd 100644 --- a/Mathlib/RingTheory/MvPolynomial/Localization.lean +++ b/Mathlib/RingTheory/MvPolynomial/Localization.lean @@ -97,15 +97,19 @@ private lemma auxHom_auxInv : (auxHom S r).toRingHom.comp (auxInv S r) = RingHom apply IsLocalization.ringHom_ext (Submonoid.powers r) ext x simp [auxInv] + rw (transparency := .default) [auxHom_mk, aeval_C] private lemma auxInv_auxHom : (auxInv S r).comp (auxHom (S := S) r).toRingHom = RingHom.id _ := by rw [← RingHom.cancel_right (Ideal.Quotient.mk_surjective)] ext x - · simp [auxInv] + · simp only [RingHom.coe_comp, Function.comp_apply, RingHom.id_apply] + rw (transparency := .default) [auxHom_mk, aeval_C] + simp [auxInv] · simp only [auxInv, AlgHom.toRingHom_eq_coe, RingHom.coe_comp, RingHom.coe_coe, - Function.comp_apply, auxHom_mk, aeval_X, RingHomCompTriple.comp_eq, invSelf, Away.lift, - lift_mk'_spec] - simp only [map_one] + Function.comp_apply, RingHomCompTriple.comp_eq] + rw (transparency := .default) [auxHom_mk, aeval_X] + simp only [invSelf, Away.lift, lift_mk'_spec] + simp only [RingHom.comp_apply, map_one] rw [← map_one (Ideal.Quotient.mk _), ← map_mul, Ideal.Quotient.mk_eq_mk_iff_sub_mem, ← Ideal.neg_mem_iff, neg_sub] exact Ideal.mem_span_singleton_self (C r * X x - 1) From 7b7ce4070f1f5edaf4cae041ddb8ca71fdfb99eb Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 02:26:29 +0200 Subject: [PATCH 20/30] Let's fix the errors rather than avoiding --- Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean b/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean index 198649299c8421..f33246f0512e5d 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Monoidal/Basic.lean @@ -308,7 +308,7 @@ instance MonoidalCategory.instMonoidalCategoryStruct : rightUnitor M := (TensorProduct.rid R M).toModuleIso instance monoidalCategory : MonoidalCategory (ModuleCat.{u} R) := - Monoidal.induced equivalenceSemimoduleCat.functor + fast_instance% Monoidal.induced equivalenceSemimoduleCat.functor { μIso _ _ := .refl _ εIso := .refl _ associator_eq _ _ _ := by ext1; exact TensorProduct.ext (TensorProduct.ext rfl) From ff8d73faa6b719db6665d75afaccc70e5609640a Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 02:30:13 +0200 Subject: [PATCH 21/30] linter --- Mathlib/RingTheory/MvPolynomial/Localization.lean | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Mathlib/RingTheory/MvPolynomial/Localization.lean b/Mathlib/RingTheory/MvPolynomial/Localization.lean index 1baa2dd89679dd..f3bc9dd7a7a7a7 100644 --- a/Mathlib/RingTheory/MvPolynomial/Localization.lean +++ b/Mathlib/RingTheory/MvPolynomial/Localization.lean @@ -96,8 +96,9 @@ def auxInv : S →+* (MvPolynomial Unit R) ⧸ Ideal.span { C r * X () - 1 } := private lemma auxHom_auxInv : (auxHom S r).toRingHom.comp (auxInv S r) = RingHom.id S := by apply IsLocalization.ringHom_ext (Submonoid.powers r) ext x - simp [auxInv] - rw (transparency := .default) [auxHom_mk, aeval_C] + simp only [AlgHom.toRingHom_eq_coe, auxInv, RingHom.coe_comp, RingHom.coe_coe, + Function.comp_apply, lift_eq, RingHomCompTriple.comp_eq] + erw [auxHom_mk, aeval_C] private lemma auxInv_auxHom : (auxInv S r).comp (auxHom (S := S) r).toRingHom = RingHom.id _ := by rw [← RingHom.cancel_right (Ideal.Quotient.mk_surjective)] From 54b838751e6aab2c6d865a8d8995120f113fbf38 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 02:34:09 +0200 Subject: [PATCH 22/30] fix --- .../RingTheory/Ideal/CotangentBaseChange.lean | 48 +++++++++++++++---- .../RingTheory/MvPolynomial/Localization.lean | 2 +- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/Mathlib/RingTheory/Ideal/CotangentBaseChange.lean b/Mathlib/RingTheory/Ideal/CotangentBaseChange.lean index 5a330ea37155cd..b2ba010bb4b1cb 100644 --- a/Mathlib/RingTheory/Ideal/CotangentBaseChange.lean +++ b/Mathlib/RingTheory/Ideal/CotangentBaseChange.lean @@ -43,23 +43,36 @@ if `T` is `R`-flat (`tensorCotangentHom_injective_of_flat`). -/ def tensorCotangentHom : T ⊗[R] I.Cotangent →ₗ[T] (I.map <| (Algebra.TensorProduct.includeRight.toRingHom : S →+* T ⊗[R] S)).Cotangent := + let a : S →+* T ⊗[R] S := Algebra.TensorProduct.includeRight.toRingHom + letI : IsScalarTower R (T ⊗[R] S) (I.map a).Cotangent := + Submodule.Quotient.isScalarTower + (P := ((I.map a) • ⊤ : Submodule (T ⊗[R] S) (I.map a))) + (S := R) (T := T ⊗[R] S) + letI : LinearMap.CompatibleSMul (I.map a) (I.map a).Cotangent R (T ⊗[R] S) := + LinearMap.IsScalarTower.compatibleSMul LinearMap.liftBaseChange T <| Cotangent.lift - ((map (algebraMap S (T ⊗[R] S)) I).toCotangent.restrictScalars R ∘ₗ + ((I.map a).toCotangent.restrictScalars R ∘ₗ (Algebra.idealMap _ I).restrictScalars R) <| fun x y ↦ by - simp only [AlgHom.toRingHom_eq_coe, LinearMap.coe_comp, LinearMap.coe_restrictScalars, - Function.comp_apply, Algebra.idealMap_mul] - simp only [RingHom.algebraMap_toAlgebra, AlgHom.toRingHom_eq_coe, LinearMap.coe_restrictScalars, - toCotangent_eq_zero, sq, MulMemClass.coe_mul] - exact mul_mem_mul ((Algebra.idealMap (T ⊗[R] S) I) x).property - ((Algebra.idealMap (T ⊗[R] S) I) y).property + simp only [AlgHom.toRingHom_eq_coe, LinearMap.coe_comp, Function.comp_apply] + exact ((I.map a).toCotangent_eq_zero _).mpr <| by + have h : + ((((Algebra.idealMap (T ⊗[R] S) I).restrictScalars R) (x * y) : + I.map a) : T ⊗[R] S) = + ((Algebra.idealMap (T ⊗[R] S) I) x : T ⊗[R] S) * + ((Algebra.idealMap (T ⊗[R] S) I) y : T ⊗[R] S) := by + exact congrArg Subtype.val (Algebra.idealMap_mul (T ⊗[R] S) I x y) + exact h.symm ▸ (by + simpa [sq] using mul_mem_mul ((Algebra.idealMap (T ⊗[R] S) I) x).property + ((Algebra.idealMap (T ⊗[R] S) I) y).property) -- TODO: make this @[simp] when `Ideal.map` is refactored to only take `RingHom`s lemma tensorCotangentHom_tmul (t : T) (x : I) : tensorCotangentHom R T I (t ⊗ₜ[R] I.toCotangent x) = t • (I.map Algebra.TensorProduct.includeRight.toRingHom).toCotangent ⟨1 ⊗ₜ x, Ideal.mem_map_of_mem _ x.2⟩ := by - rfl + rw [tensorCotangentHom, LinearMap.liftBaseChange_tmul, Cotangent.lift_toCotangent] + congr 1 lemma tensorCotangentHom_surjective : Function.Surjective (I.tensorCotangentHom R T) := by @@ -84,6 +97,13 @@ lemma tensorCotangentHom_surjective : lemma tensorCotangentHom_injective_of_flat [Module.Flat R T] : Function.Injective (I.tensorCotangentHom R T) := by let a : S →+* T ⊗[R] S := Algebra.TensorProduct.includeRight.toRingHom + letI : IsScalarTower T (T ⊗[R] S) (I.map a).Cotangent := + Submodule.Quotient.isScalarTower + (P := ((I.map a) • ⊤ : Submodule (T ⊗[R] S) (I.map a))) + (S := T) (T := T ⊗[R] S) + letI : LinearMap.CompatibleSMul (I.map a).Cotangent (T ⊗[R] S ⧸ (I.map a) ^ 2) + T (T ⊗[R] S) := + LinearMap.IsScalarTower.compatibleSMul let f : (I.map a).Cotangent →ₗ[T] T ⊗[R] S ⧸ (I.map a) ^ 2 := (Ideal.cotangentToQuotientSquare _).restrictScalars T suffices h : Function.Injective (f ∘ₗ tensorCotangentHom R T I) from .of_comp h @@ -97,7 +117,15 @@ lemma tensorCotangentHom_injective_of_flat [Module.Flat R T] : obtain ⟨x, rfl⟩ := I.toCotangent_surjective x dsimp [f, g, hₐ] rw [tensorCotangentHom_tmul, one_smul, Ideal.toCotangent_to_quotient_square] - simp + have hq : + (Algebra.TensorProduct.tensorQuotientEquiv T S T (I ^ 2)) + (1 ⊗ₜ[R] (Ideal.Quotient.mk (I ^ 2) (x : S))) = + Ideal.Quotient.mk ((I ^ 2).map + (Algebra.TensorProduct.includeRight : S →ₐ[R] T ⊗[R] S)) (1 ⊗ₜ[R] (x : S)) := by + exact Algebra.TensorProduct.tensorQuotientEquiv_apply_tmul + (R := R) (S := T) (T := S) (A := T) (I := I ^ 2) (a := 1) (t := (x : S)) + rw [hq, Ideal.quotientEquivAlgOfEq_mk] + rfl rw [this, LinearMap.coe_comp] apply hₐ.injective.comp · apply Module.Flat.lTensor_preserves_injective_linearMap (M := T) @@ -117,6 +145,6 @@ lemma tensorCotangentEquiv_tmul [Module.Flat R T] (t : T) (x : I) : I.tensorCotangentEquiv R T (t ⊗ₜ I.toCotangent x) = t • (I.map Algebra.TensorProduct.includeRight.toRingHom).toCotangent ⟨1 ⊗ₜ x, Ideal.mem_map_of_mem _ x.2⟩ := - rfl + tensorCotangentHom_tmul R T I t x end Ideal diff --git a/Mathlib/RingTheory/MvPolynomial/Localization.lean b/Mathlib/RingTheory/MvPolynomial/Localization.lean index f3bc9dd7a7a7a7..35c22a0cdc56ac 100644 --- a/Mathlib/RingTheory/MvPolynomial/Localization.lean +++ b/Mathlib/RingTheory/MvPolynomial/Localization.lean @@ -98,7 +98,7 @@ private lemma auxHom_auxInv : (auxHom S r).toRingHom.comp (auxInv S r) = RingHom ext x simp only [AlgHom.toRingHom_eq_coe, auxInv, RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply, lift_eq, RingHomCompTriple.comp_eq] - erw [auxHom_mk, aeval_C] + rw (transparency := .default) [auxHom_mk, aeval_C] private lemma auxInv_auxHom : (auxInv S r).comp (auxHom (S := S) r).toRingHom = RingHom.id _ := by rw [← RingHom.cancel_right (Ideal.Quotient.mk_surjective)] From a11dfb5d1839ad78734365252f94136e935d4ad8 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 02:40:49 +0200 Subject: [PATCH 23/30] this is done --- Mathlib/RingTheory/Flat/FaithfullyFlat/Algebra.lean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mathlib/RingTheory/Flat/FaithfullyFlat/Algebra.lean b/Mathlib/RingTheory/Flat/FaithfullyFlat/Algebra.lean index b043b91f8e57c3..8093c334e2e43b 100644 --- a/Mathlib/RingTheory/Flat/FaithfullyFlat/Algebra.lean +++ b/Mathlib/RingTheory/Flat/FaithfullyFlat/Algebra.lean @@ -123,7 +123,7 @@ lemma Ideal.comap_map_eq_self_of_faithfullyFlat (I : Ideal A) : have : ((quotIdealMapEquivTensorQuot B I).symm.toLinearEquiv.toLinearMap.restrictScalars _ ∘ₗ TensorProduct.mk A B (A ⧸ I) 1) x = 0 := by simp [← Algebra.algebraMap_eq_smul_one, hx] - simp [this] + simpa using this /-- If `B` is a faithfully-flat `A`-algebra, every ideal in `A` is the preimage of some ideal in `B`. -/ From c8805a934e2d4c7e2cd9834ed1a88a72f35bee12 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 10:40:02 +0200 Subject: [PATCH 24/30] fix --- .../ModuleCat/Monoidal/Symmetric.lean | 23 +++++++++++++-- .../Extension/Presentation/Core.lean | 29 +++++++++++++++++-- Mathlib/RingTheory/Invariant/Basic.lean | 5 +++- Mathlib/RingTheory/Smooth/Basic.lean | 7 +++-- Mathlib/RingTheory/Smooth/Kaehler.lean | 20 +++++++++++-- 5 files changed, 73 insertions(+), 11 deletions(-) diff --git a/Mathlib/Algebra/Category/ModuleCat/Monoidal/Symmetric.lean b/Mathlib/Algebra/Category/ModuleCat/Monoidal/Symmetric.lean index 25b426ccad1f58..ca1cdedb81311d 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Monoidal/Symmetric.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Monoidal/Symmetric.lean @@ -111,8 +111,21 @@ namespace ModuleCat.MonoidalCategory variable {R : Type u} [CommRing R] +local instance : equivalenceSemimoduleCat (R := R).functor.Monoidal := + CategoryTheory.Monoidal.fromInducedMonoidal equivalenceSemimoduleCat.functor + { μIso _ _ := .refl _ + εIso := .refl _ + associator_eq _ _ _ := by ext1; exact TensorProduct.ext (TensorProduct.ext rfl) + leftUnitor_eq _ := by ext1; exact TensorProduct.ext rfl + rightUnitor_eq _ := by ext1; exact TensorProduct.ext rfl } + instance : BraidedCategory (ModuleCat.{u} R) := .ofFaithful equivalenceSemimoduleCat.functor (fun M N ↦ (TensorProduct.comm R M N).toModuleIso) + (fun M N ↦ by + ext : 1 + apply TensorProduct.ext' + intro m n + rfl) instance : equivalenceSemimoduleCat (R := R).functor.Braided where @@ -129,14 +142,18 @@ theorem braiding_inv_apply {M N : ModuleCat.{u} R} (m : M) (n : N) : ((β_ M N).inv : N ⊗ M ⟶ M ⊗ N) (n ⊗ₜ m) = m ⊗ₜ n := rfl +set_option backward.isDefEq.respectTransparency false in theorem tensorμ_eq_tensorTensorTensorComm {A B C D : ModuleCat R} : tensorμ A B C D = ofHom (TensorProduct.tensorTensorTensorComm R A B C D).toLinearMap := - ModuleCat.hom_ext <| TensorProduct.ext <| TensorProduct.ext <| LinearMap.ext₂ fun _ _ => - TensorProduct.ext <| LinearMap.ext₂ fun _ _ => rfl + ModuleCat.hom_ext <| TensorProduct.ext <| TensorProduct.ext <| LinearMap.ext₂ fun a b => + TensorProduct.ext <| LinearMap.ext₂ fun c d => by + rfl @[simp] theorem tensorμ_apply {A B C D : ModuleCat R} (x : A) (y : B) (z : C) (w : D) : - tensorμ A B C D ((x ⊗ₜ y) ⊗ₜ (z ⊗ₜ w)) = (x ⊗ₜ z) ⊗ₜ (y ⊗ₜ w) := rfl + tensorμ A B C D ((x ⊗ₜ y) ⊗ₜ (z ⊗ₜ w)) = (x ⊗ₜ z) ⊗ₜ (y ⊗ₜ w) := by + rw [tensorμ_eq_tensorTensorTensorComm] + rfl end ModuleCat.MonoidalCategory diff --git a/Mathlib/RingTheory/Extension/Presentation/Core.lean b/Mathlib/RingTheory/Extension/Presentation/Core.lean index 0e3a5b9dd35491..4f720ec60b0c45 100644 --- a/Mathlib/RingTheory/Extension/Presentation/Core.lean +++ b/Mathlib/RingTheory/Extension/Presentation/Core.lean @@ -179,14 +179,37 @@ lemma tensorModelOfHasCoeffsHom_comp : (P.quotientEquiv.restrictScalars R).surjective.comp Ideal.Quotient.mk_surjective simp only [← AlgHom.cancel_right h, tensorModelOfHasCoeffsInv, AlgHom.id_comp] rw [AlgHom.comp_assoc, AlgHom.comp_assoc, ← AlgHom.comp_assoc _ _ (Ideal.Quotient.mkₐ R P.ker), - AlgEquiv.symm_comp, AlgHom.id_comp] + AlgEquiv.symm_comp, AlgHom.id_comp, Ideal.Quotient.liftₐ_comp] ext x - simp + calc + _ = P.tensorModelOfHasCoeffsHom R₀ + (1 ⊗ₜ[R₀] (Ideal.Quotient.mk + (Ideal.span <| Set.range (P.relationOfHasCoeffs R₀)) (MvPolynomial.X x))) := by + simp [MvPolynomial.algebraTensorAlgEquiv_symm_X] + _ = MvPolynomial.aeval P.val (MvPolynomial.X x) := by + have hhom : + P.tensorModelOfHasCoeffsHom R₀ + (1 ⊗ₜ[R₀] (Ideal.Quotient.mk + (Ideal.span <| Set.range (P.relationOfHasCoeffs R₀)) (MvPolynomial.X x))) = + algebraMap R S (1 : R) * MvPolynomial.aeval P.val (MvPolynomial.X x) := rfl + simpa using hhom + _ = P.quotientEquiv ((Ideal.Quotient.mk P.ker) (MvPolynomial.X x)) := by + change MvPolynomial.aeval (R := R) P.val (MvPolynomial.X x) = + algebraMap P.Ring S (MvPolynomial.X x : P.Ring) + rw [P.algebraMap_apply] lemma tensorModelOfHasCoeffsInv_comp : (P.tensorModelOfHasCoeffsInv R₀).comp (P.tensorModelOfHasCoeffsHom R₀) = AlgHom.id R _ := by - ext x + apply Algebra.TensorProduct.ext' + intro r x obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x + have hhom : + P.tensorModelOfHasCoeffsHom R₀ + (r ⊗ₜ[R₀] (Ideal.Quotient.mk + (Ideal.span <| Set.range (P.relationOfHasCoeffs R₀)) x)) = + algebraMap R S r * MvPolynomial.aeval P.val x := rfl + simp only [AlgHom.comp_apply, AlgHom.id_apply] + rw [hhom, map_mul, tensorModelOfHasCoeffsInv_aeval_val] simp /-- The natural isomorphism `R ⊗[R₀] S₀ ≃ₐ[R] S`. -/ diff --git a/Mathlib/RingTheory/Invariant/Basic.lean b/Mathlib/RingTheory/Invariant/Basic.lean index ea74ac476c0603..9b0a358a3754f8 100644 --- a/Mathlib/RingTheory/Invariant/Basic.lean +++ b/Mathlib/RingTheory/Invariant/Basic.lean @@ -355,7 +355,10 @@ omit [Finite G] [Q.IsPrime] [Algebra.IsInvariant A B G] in theorem IsFractionRing.stabilizerHom_apply_apply_mk (σ : MulAction.stabilizer G Q) (x : B) : IsFractionRing.stabilizerHom G P Q K L σ (algebraMap _ L (Ideal.Quotient.mk Q x)) = algebraMap _ L (Ideal.Quotient.mk Q (σ.val • x)) := by - simp [IsFractionRing.stabilizerHom, MulAction.subgroup_smul_def] + simp only [IsFractionRing.stabilizerHom, MonoidHom.coe_comp, Function.comp_apply, + IsFractionRing.fieldEquivOfAlgEquivHom_apply, IsFractionRing.fieldEquivOfAlgEquiv_algebraMap] + simpa using congrArg (algebraMap (B ⧸ Q) L) + (Ideal.Quotient.stabilizerHom_apply (P := Q) (p := P) (G := G) σ x) /-- This theorem will be made redundant by `IsFractionRing.stabilizerHom_surjective`. -/ private theorem fixed_of_fixed2 (f : Gal(L/K)) (x : L) diff --git a/Mathlib/RingTheory/Smooth/Basic.lean b/Mathlib/RingTheory/Smooth/Basic.lean index f64c55d51a53bf..8d0630d840a667 100644 --- a/Mathlib/RingTheory/Smooth/Basic.lean +++ b/Mathlib/RingTheory/Smooth/Basic.lean @@ -91,8 +91,11 @@ lemma FormallySmooth.comp_surjective [FormallySmooth R A] (I : Ideal B) (hI : I l.restrictScalars P.toExtension.Ring, LinearMap.ext fun x ↦ congr($hl x)⟩ let σ := Function.surjInv (f := algebraMap B (B ⧸ I)) Ideal.Quotient.mk_surjective have H (x : P.Ring) : ↑(aeval (σ ∘ f) x) = f (algebraMap _ A x) := by - rw [← Ideal.Quotient.algebraMap_eq, ← aeval_algebraMap_apply, P.algebraMap_eq, - AlgHom.coe_toRingHom, comp_aeval_apply, ← Function.comp_assoc, Function.comp_surjInv,] + change algebraMap B (B ⧸ I) (MvPolynomial.aeval (σ ∘ f) x) = + f (algebraMap P.Ring A x) + rw [← MvPolynomial.aeval_algebraMap_apply (B := B ⧸ I) (x := σ ∘ f) (p := x), + P.algebraMap_eq, AlgHom.coe_toRingHom, comp_aeval_apply, + ← Function.comp_assoc, Function.comp_surjInv] simp [P] let l : P.Ring ⧸ (RingHom.ker (algebraMap P.Ring A)) ^ 2 →ₐ[R] B := Ideal.Quotient.liftₐ _ (aeval (σ ∘ f)) <| diff --git a/Mathlib/RingTheory/Smooth/Kaehler.lean b/Mathlib/RingTheory/Smooth/Kaehler.lean index 930f2a4d5f1ff2..e040e772d8cdc3 100644 --- a/Mathlib/RingTheory/Smooth/Kaehler.lean +++ b/Mathlib/RingTheory/Smooth/Kaehler.lean @@ -273,6 +273,7 @@ def derivationQuotKerSq : lemma derivationQuotKerSq_mk (x : P) : derivationQuotKerSq R P S x = 1 ⊗ₜ .D R P x := rfl +set_option linter.flexible false in variable (R P S) in /-- Given a tower of algebras `S/P/R`, with `I = ker(P → S)` and `Q := P/I²`, @@ -294,17 +295,32 @@ def tensorKaehlerQuotKerSqEquiv : ext a obtain ⟨a, rfl⟩ := Ideal.Quotient.mk_surjective a simp [f₁, f₂, f₃, f₄, f₅] + have hd : + (derivationQuotKerSq R P S) + ((Ideal.Quotient.mk (RingHom.ker (algebraMap P S) ^ 2)) a) = + 1 ⊗ₜ[P] KaehlerDifferential.D R P a := + derivationQuotKerSq_mk (R := R) (P := P) (S := S) a + rw [hd] + simp [KaehlerDifferential.map_D] right_inv := by suffices f₂.comp f₅ = LinearMap.id from LinearMap.congr_fun this ext a - simp [f₁, f₂, f₃, f₄, f₅] } + simp [f₁, f₂, f₃, f₄, f₅] + exact derivationQuotKerSq_mk (R := R) (P := P) (S := S) a } @[simp] lemma tensorKaehlerQuotKerSqEquiv_tmul_D (s t) : tensorKaehlerQuotKerSqEquiv R P S (s ⊗ₜ .D _ _ (Ideal.Quotient.mk _ t)) = s ⊗ₜ .D _ _ t := by change s • (derivationQuotKerSq R P S).liftKaehlerDifferential (.D _ _ (Ideal.Quotient.mk _ t)) = _ - simp [smul_tmul'] + rw [Derivation.liftKaehlerDifferential_comp_D] + have hd : + (derivationQuotKerSq R P S) + ((Ideal.Quotient.mk (RingHom.ker (algebraMap P S) ^ 2)) t) = + 1 ⊗ₜ[P] KaehlerDifferential.D R P t := + derivationQuotKerSq_mk (R := R) (P := P) (S := S) t + rw [hd] + rw [TensorProduct.smul_tmul', smul_eq_mul, mul_one] @[simp] lemma tensorKaehlerQuotKerSqEquiv_symm_tmul_D (s t) : From 44493bd06fa53de2230c5b096845f741625a97f1 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 10:42:20 +0200 Subject: [PATCH 25/30] another one --- Mathlib/RingTheory/Etale/StandardEtale.lean | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mathlib/RingTheory/Etale/StandardEtale.lean b/Mathlib/RingTheory/Etale/StandardEtale.lean index 23a435abd48b17..095a24dbaa80f0 100644 --- a/Mathlib/RingTheory/Etale/StandardEtale.lean +++ b/Mathlib/RingTheory/Etale/StandardEtale.lean @@ -244,7 +244,8 @@ set_option backward.isDefEq.respectTransparency false in @[simp] lemma equivMvPolynomialQuotient_symm_apply : P.equivMvPolynomialQuotient.symm (Ideal.Quotient.mk _ (.X 0)) = P.X := by - simp [equivMvPolynomialQuotient, StandardEtalePair.Ring]; rfl + simp [equivMvPolynomialQuotient, StandardEtalePair.Ring, StandardEtalePair.X, + Ideal.quotientEquivAlg_symm] /-- Mapping a standard etale pair under a ring homomorphism. -/ @[simps] protected noncomputable def map (f : R →+* S) : StandardEtalePair S where From 98333c708a56e68873859532cf2bdf9f7d4616c4 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 10:49:47 +0200 Subject: [PATCH 26/30] ops --- Mathlib/RingTheory/Etale/StandardEtale.lean | 17 ++++++++++++++++- Mathlib/RingTheory/Smooth/Pi.lean | 13 ++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Mathlib/RingTheory/Etale/StandardEtale.lean b/Mathlib/RingTheory/Etale/StandardEtale.lean index 095a24dbaa80f0..7094fa7c2cf23c 100644 --- a/Mathlib/RingTheory/Etale/StandardEtale.lean +++ b/Mathlib/RingTheory/Etale/StandardEtale.lean @@ -244,8 +244,23 @@ set_option backward.isDefEq.respectTransparency false in @[simp] lemma equivMvPolynomialQuotient_symm_apply : P.equivMvPolynomialQuotient.symm (Ideal.Quotient.mk _ (.X 0)) = P.X := by - simp [equivMvPolynomialQuotient, StandardEtalePair.Ring, StandardEtalePair.X, + let I : Ideal (MvPolynomial (Fin 2) R) := Ideal.span + {(Bivariate.equivMvPolynomial R) (C P.f), + (Bivariate.equivMvPolynomial R) (Y * C P.g - 1)} + let J : Ideal R[X][Y] := Ideal.span {C P.f, Y * C P.g - 1} + let e : R[X][Y] ≃ₐ[R] MvPolynomial (Fin 2) R := Bivariate.equivMvPolynomial R + have hIJ : I = J.map (e : R[X][Y] →+* MvPolynomial (Fin 2) R) := by + simp only [I, J, e, Ideal.map_span, Set.image_insert_eq, Set.image_singleton] + rfl + have hJI : J = I.map (e.symm : MvPolynomial (Fin 2) R →+* R[X][Y]) := by + simp only [← AlgEquiv.toAlgHom_toRingHom, hIJ, Ideal.map_map, + ← AlgHom.comp_toRingHom, AlgEquiv.symm_comp, AlgHom.id_toRingHom, Ideal.map_id] + simp only [equivMvPolynomialQuotient, StandardEtalePair.Ring, StandardEtalePair.X, Ideal.quotientEquivAlg_symm] + change (Ideal.quotientEquivAlg I J e.symm hJI) + (Ideal.Quotient.mk I (MvPolynomial.X 0)) = Ideal.Quotient.mk J (C X) + simpa only [e, Bivariate.equivMvPolynomial_symm_X_0] using + (Ideal.quotientEquivAlg_mk (I := I) J e.symm hJI (MvPolynomial.X (0 : Fin 2))) /-- Mapping a standard etale pair under a ring homomorphism. -/ @[simps] protected noncomputable def map (f : R →+* S) : StandardEtalePair S where diff --git a/Mathlib/RingTheory/Smooth/Pi.lean b/Mathlib/RingTheory/Smooth/Pi.lean index a9154eef777ce2..dba61e1eccfe4f 100644 --- a/Mathlib/RingTheory/Smooth/Pi.lean +++ b/Mathlib/RingTheory/Smooth/Pi.lean @@ -73,7 +73,11 @@ theorem pi_iff [Finite I] : rw [← Ideal.ker_quotientMap_mk]; exact hix rw [Ideal.map_span, Set.image_singleton, Ideal.mem_span_singleton] at this obtain ⟨c, rfl⟩ := this - rw [← mul_assoc, ← map_mul, mul_sub, mul_one, (he.idem i).eq, sub_self, map_zero, zero_mul] + have hzero : Ideal.Quotient.mk J (e i) * Ideal.Quotient.mk J (1 - e i) = 0 := by + rw [← (Ideal.Quotient.mk J).map_mul, mul_sub, mul_one, (he.idem i).eq, sub_self, + map_zero] + change Ideal.Quotient.mk J (e i) * (Ideal.Quotient.mk J (1 - e i) * c) = 0 + rw [← mul_assoc, hzero, zero_mul] have : ∀ i : I, ∃ a : A i →ₐ[R] B ⧸ Ideal.span {1 - e i}, ∀ x, Ideal.Quotient.mk (J' i) (a x) = ι i (g (Pi.single i x)) := by intro i @@ -115,8 +119,11 @@ theorem pi_iff [Finite I] : Ideal.Quotient.algebraMap_eq, Ideal.Quotient.mkₐ_eq_mk, ι] rw [← sub_eq_zero, ← map_sub] at this replace this := hι _ _ this - rwa [mul_sub, ← map_mul, mul_comm, mul_assoc, (he.idem i).eq, he', ← map_mul, ← Pi.single_mul, - one_mul, sub_eq_zero] at this + rw [mul_sub] at this + change Ideal.Quotient.mk J (e i) * Ideal.Quotient.mk J (y * e i) - + Ideal.Quotient.mk J (e i) * g (Pi.single i x) = 0 at this + rwa [← (Ideal.Quotient.mk J).map_mul, mul_comm, mul_assoc, (he.idem i).eq, he', + ← map_mul, ← Pi.single_mul, one_mul, sub_eq_zero] at this instance [Finite I] [∀ i, FormallySmooth R (A i)] : FormallySmooth R (Π i, A i) := (pi_iff _).mpr ‹_› From 61fd75ef418469cd9833faf6394cdab420a6aac9 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 10:51:56 +0200 Subject: [PATCH 27/30] two more --- .../Extension/Cotangent/LocalizationAway.lean | 3 ++- Mathlib/RingTheory/Frobenius.lean | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Mathlib/RingTheory/Extension/Cotangent/LocalizationAway.lean b/Mathlib/RingTheory/Extension/Cotangent/LocalizationAway.lean index f92840722ac26e..60fd83b5a483c6 100644 --- a/Mathlib/RingTheory/Extension/Cotangent/LocalizationAway.lean +++ b/Mathlib/RingTheory/Extension/Cotangent/LocalizationAway.lean @@ -148,7 +148,8 @@ lemma liftBaseChange_injective_of_isLocalizationAway : rw [show g = algebraMap P.Ring S (P.σ g) by simp, ← map_pow, algebraMap_smul, ← map_smul, Extension.Cotangent.mk_eq_zero_iff] simpa using hm - rw [← compLocalizationAwayAlgHom_toAlgHom_toComp (T := T)] + dsimp [f] + rw [← compLocalizationAwayAlgHom_toAlgHom_toComp (T := T) g P x.val] apply sq_ker_comp_le_ker_compLocalizationAwayAlgHom simpa only [LinearEquiv.coe_coe, LinearMap.ringLmapEquivSelf_symm_apply, mk_apply, lift.tmul, LinearMap.coe_restrictScalars, LinearMap.coe_smulRight, diff --git a/Mathlib/RingTheory/Frobenius.lean b/Mathlib/RingTheory/Frobenius.lean index e0b10ae2bb310e..1c22e08aeeef26 100644 --- a/Mathlib/RingTheory/Frobenius.lean +++ b/Mathlib/RingTheory/Frobenius.lean @@ -61,7 +61,9 @@ variable {φ ψ : S →ₐ[R] S} {Q : Ideal S} (H : φ.IsArithFrobAt Q) include H lemma mk_apply (x) : Ideal.Quotient.mk Q (φ x) = x ^ Nat.card (R ⧸ Q.under R) := by - rw [← map_pow, Ideal.Quotient.eq] + change Ideal.Quotient.mk Q (φ x) = + (Ideal.Quotient.mk Q x) ^ Nat.card (R ⧸ Q.under R) + rw [← (Ideal.Quotient.mk Q).map_pow x (Nat.card (R ⧸ Q.under R)), Ideal.Quotient.eq] exact H x lemma finite_quotient : _root_.Finite (R ⧸ Q.under R) := by @@ -76,8 +78,9 @@ lemma card_pos : 0 < Nat.card (R ⧸ Q.under R) := lemma le_comap : Q ≤ Q.comap φ := by intro x hx - simp_all only [Ideal.mem_comap, ← Ideal.Quotient.eq_zero_iff_mem (I := Q), H.mk_apply, - zero_pow_eq, ite_eq_right_iff, H.card_pos.ne', false_implies] + rw [Ideal.mem_comap, ← Ideal.Quotient.eq_zero_iff_mem (I := Q), H.mk_apply] + change (Ideal.Quotient.mk Q x) ^ Nat.card (R ⧸ Q.under R) = 0 + rw [Ideal.Quotient.eq_zero_iff_mem.mpr hx, zero_pow H.card_pos.ne'] /-- A Frobenius element at `Q` restricts to the Frobenius map on `S ⧸ Q`. -/ def restrict : S ⧸ Q →ₐ[R ⧸ Q.under R] S ⧸ Q where @@ -101,8 +104,12 @@ lemma restrict_injective [Q.IsPrime] : lemma comap_eq [Q.IsPrime] : Q.comap φ = Q := by refine le_antisymm (fun x hx ↦ ?_) H.le_comap - rwa [← Ideal.Quotient.eq_zero_iff_mem, ← H.restrict_injective.eq_iff, map_zero, restrict_mk, - Ideal.Quotient.eq_zero_iff_mem, ← Ideal.mem_comap] + have h0 : H.restrict (Ideal.Quotient.mk Q x) = 0 := + (H.restrict_mk x).trans (Ideal.Quotient.eq_zero_iff_mem.mpr hx) + rw [← Ideal.Quotient.eq_zero_iff_mem] + apply H.restrict_injective + rw [map_zero] + exact h0 /-- Suppose `S` is a domain, and `φ : S →ₐ[R] S` is a Frobenius at `Q : Ideal S`. Let `ζ` be a `m`-th root of unity with `Q ∤ m`, then `φ` sends `ζ` to `ζ ^ q`. -/ From 9849b61f0841ba9fd8371e97ad5bfb466793c905 Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 10:58:28 +0200 Subject: [PATCH 28/30] fix --- Mathlib/RingTheory/Extension/Cotangent/Basis.lean | 4 +++- Mathlib/RingTheory/Smooth/NoetherianDescent.lean | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Mathlib/RingTheory/Extension/Cotangent/Basis.lean b/Mathlib/RingTheory/Extension/Cotangent/Basis.lean index 1e7ce2133a4172..a9cd134b0c082e 100644 --- a/Mathlib/RingTheory/Extension/Cotangent/Basis.lean +++ b/Mathlib/RingTheory/Extension/Cotangent/Basis.lean @@ -88,7 +88,8 @@ abbrev gbar : D.T := D.g set_option backward.isDefEq.respectTransparency false in /-- `S` is the localization of `T` away from `S`. -/ instance : IsLocalization.Away D.gbar S := by - refine .of_surjective_of_isScalarTower (n := 1) ?_ ?_ _ ?_ (by simpa using D.hg) + refine IsLocalization.Away.of_surjective_of_isScalarTower + (R := P.Ring) (S := D.T) (T := S) (n := 1) ?_ ?_ D.g ?_ ?_ · refine .of_comp (g := algebraMap P.Ring D.T) ?_ convert! P.algebraMap_surjective ext x @@ -97,6 +98,7 @@ instance : IsLocalization.Away D.gbar S := by · suffices h : (algebraMap P.Ring S) D.g = 1 by simp [h] rw [← map_one (algebraMap P.Ring S), ← sub_eq_zero, ← map_sub, ← RingHom.mem_ker] exact D.hgmem + · simpa using D.hg open Classical in /-- The "naive" presentation of `T = R[X₁, ..., Xₙ] / (b₁, ..., bᵣ)` over `R`. diff --git a/Mathlib/RingTheory/Smooth/NoetherianDescent.lean b/Mathlib/RingTheory/Smooth/NoetherianDescent.lean index 864beb323b18d2..a336ff8534e32a 100644 --- a/Mathlib/RingTheory/Smooth/NoetherianDescent.lean +++ b/Mathlib/RingTheory/Smooth/NoetherianDescent.lean @@ -219,9 +219,12 @@ public theorem exists_subalgebra_fg [Smooth A B] : choose p homog hp using this have hsig (i : _) : f (h i) = P.val i := by rw [← AlgHom.kerSquareLift_mk] - -- Reducible def-eq issues caused by `RingHom.ker f.toRingHom` discrepancies - -- Can be fixed after #25138. - exact hh i ▸ congr($hsig (P.val i)) + change f.kerSquareLift ((Ideal.Quotient.mk (RingHom.ker f ^ 2)) (h i)) = P.val i + calc + f.kerSquareLift ((Ideal.Quotient.mk (RingHom.ker f ^ 2)) (h i)) = + f.kerSquareLift (σ (P.val i)) := + congrArg f.kerSquareLift (hh i) + _ = P.val i := by simpa [AlgHom.comp_apply] using AlgHom.congr_fun hsig (P.val i) have (i : Fin (Presentation.ofFinitePresentationVars A B)) : h i - X i ∈ Ideal.span (.range P.relation) := by simpa [P.span_range_relation_eq_ker, sub_eq_zero, f] using hsig i From 13c8ec5f65011920ca7f6d3280032c6e6446bfdf Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 11:48:44 +0200 Subject: [PATCH 29/30] linter --- .../Category/ModuleCat/Monoidal/Symmetric.lean | 4 +++- Mathlib/Algebra/Order/Antidiag/Prod.lean | 2 +- Mathlib/RingTheory/AdicCompletion/RingHom.lean | 3 ++- .../Extension/Presentation/Basic.lean | 3 ++- .../RingTheory/Extension/Presentation/Core.lean | 17 +++++++++-------- Mathlib/RingTheory/Ideal/Over.lean | 8 +++++--- .../RingTheory/Ideal/Quotient/Operations.lean | 2 +- .../RingTheory/MvPolynomial/Localization.lean | 3 ++- Mathlib/RingTheory/Smooth/Kaehler.lean | 13 +++---------- Mathlib/RingTheory/TensorProduct/Quotient.lean | 12 ++++++++---- scripts/nolints.json | 1 + 11 files changed, 37 insertions(+), 31 deletions(-) diff --git a/Mathlib/Algebra/Category/ModuleCat/Monoidal/Symmetric.lean b/Mathlib/Algebra/Category/ModuleCat/Monoidal/Symmetric.lean index ca1cdedb81311d..338c23be3cf519 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Monoidal/Symmetric.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Monoidal/Symmetric.lean @@ -111,7 +111,9 @@ namespace ModuleCat.MonoidalCategory variable {R : Type u} [CommRing R] -local instance : equivalenceSemimoduleCat (R := R).functor.Monoidal := +/-- The monoidal structure on the equivalence between `ModuleCat` and `SemimoduleCat`. -/ +local instance instMonoidalSemimoduleCatFunctorEquivalenceSemimoduleCat : + equivalenceSemimoduleCat (R := R).functor.Monoidal := CategoryTheory.Monoidal.fromInducedMonoidal equivalenceSemimoduleCat.functor { μIso _ _ := .refl _ εIso := .refl _ diff --git a/Mathlib/Algebra/Order/Antidiag/Prod.lean b/Mathlib/Algebra/Order/Antidiag/Prod.lean index 9217a07c264188..7690bcc0fa5f67 100644 --- a/Mathlib/Algebra/Order/Antidiag/Prod.lean +++ b/Mathlib/Algebra/Order/Antidiag/Prod.lean @@ -85,7 +85,7 @@ theorem swap_mem_antidiagonal [AddCommMonoid A] [HasAntidiagonal A] {n : A} {xy xy.swap ∈ antidiagonal n ↔ xy ∈ antidiagonal n := by simp [add_comm] -@[simp] theorem map_prodComm_antidiagonal [AddCommMonoid A] [HasAntidiagonal A] {n : A} : +theorem map_prodComm_antidiagonal [AddCommMonoid A] [HasAntidiagonal A] {n : A} : (antidiagonal n).map (Equiv.prodComm A A) = antidiagonal n := Finset.ext fun ⟨a, b⟩ => by simp [add_comm] diff --git a/Mathlib/RingTheory/AdicCompletion/RingHom.lean b/Mathlib/RingTheory/AdicCompletion/RingHom.lean index 29a6258f804c40..9bfa143ae160a8 100644 --- a/Mathlib/RingTheory/AdicCompletion/RingHom.lean +++ b/Mathlib/RingTheory/AdicCompletion/RingHom.lean @@ -115,7 +115,8 @@ variable (f : (n : ℕ) → A →ₐ[R] S ⧸ I ^ n) (Ideal.Quotient.factorₐ R (Ideal.pow_le_pow_right hle)).comp (f n) = f m) @[simp] -lemma mk_liftAlgHom (n : ℕ) (x : A) : liftAlgHom I f hf x = f n x := by +lemma mk_liftAlgHom (n : ℕ) (x : A) : + (Ideal.Quotient.mk (I ^ n)) (liftAlgHom I f hf x) = f n x := by simp [liftAlgHom] @[simp] diff --git a/Mathlib/RingTheory/Extension/Presentation/Basic.lean b/Mathlib/RingTheory/Extension/Presentation/Basic.lean index 20b88f8700f9c0..8a6ef25be40418 100644 --- a/Mathlib/RingTheory/Extension/Presentation/Basic.lean +++ b/Mathlib/RingTheory/Extension/Presentation/Basic.lean @@ -87,7 +87,8 @@ noncomputable def quotientEquiv : P.Quotient ≃ₐ[P.Ring] S := rw [Algebra.ofId_apply, P.algebraMap_apply, P.aeval_val_σ] @[simp] -lemma quotientEquiv_mk (p : P.Ring) : P.quotientEquiv p = algebraMap P.Ring S p := +lemma quotientEquiv_mk (p : P.Ring) : + P.quotientEquiv (Ideal.Quotient.mk P.ker p) = algebraMap P.Ring S p := rfl @[simp] diff --git a/Mathlib/RingTheory/Extension/Presentation/Core.lean b/Mathlib/RingTheory/Extension/Presentation/Core.lean index 4f720ec60b0c45..b28b24bba1a651 100644 --- a/Mathlib/RingTheory/Extension/Presentation/Core.lean +++ b/Mathlib/RingTheory/Extension/Presentation/Core.lean @@ -147,7 +147,10 @@ noncomputable def tensorModelOfHasCoeffsHom : R ⊗[R₀] P.ModelOfHasCoeffs R @[simp] lemma tensorModelOfHasCoeffsHom_tmul (x : R) (y : MvPolynomial ι R₀) : - P.tensorModelOfHasCoeffsHom R₀ (x ⊗ₜ y) = algebraMap R S x * MvPolynomial.aeval P.val y := + P.tensorModelOfHasCoeffsHom R₀ + (x ⊗ₜ[R₀] (Ideal.Quotient.mk + (Ideal.span (Set.range (P.relationOfHasCoeffs R₀))) y)) = + algebraMap R S x * MvPolynomial.aeval P.val y := rfl variable (P) in @@ -187,12 +190,7 @@ lemma tensorModelOfHasCoeffsHom_comp : (Ideal.span <| Set.range (P.relationOfHasCoeffs R₀)) (MvPolynomial.X x))) := by simp [MvPolynomial.algebraTensorAlgEquiv_symm_X] _ = MvPolynomial.aeval P.val (MvPolynomial.X x) := by - have hhom : - P.tensorModelOfHasCoeffsHom R₀ - (1 ⊗ₜ[R₀] (Ideal.Quotient.mk - (Ideal.span <| Set.range (P.relationOfHasCoeffs R₀)) (MvPolynomial.X x))) = - algebraMap R S (1 : R) * MvPolynomial.aeval P.val (MvPolynomial.X x) := rfl - simpa using hhom + simp _ = P.quotientEquiv ((Ideal.Quotient.mk P.ker) (MvPolynomial.X x)) := by change MvPolynomial.aeval (R := R) P.val (MvPolynomial.X x) = algebraMap P.Ring S (MvPolynomial.X x : P.Ring) @@ -219,7 +217,10 @@ noncomputable def tensorModelOfHasCoeffsEquiv : R ⊗[R₀] P.ModelOfHasCoeffs R @[simp] lemma tensorModelOfHasCoeffsEquiv_tmul (x : R) (y : MvPolynomial ι R₀) : - P.tensorModelOfHasCoeffsEquiv R₀ (x ⊗ₜ y) = algebraMap R S x * MvPolynomial.aeval P.val y := + P.tensorModelOfHasCoeffsEquiv R₀ + (x ⊗ₜ[R₀] (Ideal.Quotient.mk + (Ideal.span (Set.range (P.relationOfHasCoeffs R₀))) y)) = + algebraMap R S x * MvPolynomial.aeval P.val y := rfl @[simp] diff --git a/Mathlib/RingTheory/Ideal/Over.lean b/Mathlib/RingTheory/Ideal/Over.lean index 376c113a794823..0bb088f5237a30 100644 --- a/Mathlib/RingTheory/Ideal/Over.lean +++ b/Mathlib/RingTheory/Ideal/Over.lean @@ -308,7 +308,8 @@ def algEquivOfEqMap (h : Q = P.map σ) : (B ⧸ P) ≃ₐ[A ⧸ p] (C ⧸ Q) whe exact congrArg (Ideal.Quotient.mk Q) (AlgHomClass.commutes σ x) @[simp] -theorem algEquivOfEqMap_apply (h : Q = P.map σ) (x : B) : algEquivOfEqMap p σ h x = σ x := +theorem algEquivOfEqMap_apply (h : Q = P.map σ) (x : B) : + algEquivOfEqMap p σ h (Ideal.Quotient.mk P x) = σ x := rfl /-- An `A ⧸ p`-algebra isomorphism between `B ⧸ P` and `C ⧸ Q` induced by an `A`-algebra @@ -317,7 +318,8 @@ def algEquivOfEqComap (h : P = Q.comap σ) : (B ⧸ P) ≃ₐ[A ⧸ p] (C ⧸ Q) algEquivOfEqMap p σ ((congrArg (map σ) h).trans (Q.map_comap_eq_self_of_equiv σ)).symm @[simp] -theorem algEquivOfEqComap_apply (h : P = Q.comap σ) (x : B) : algEquivOfEqComap p σ h x = σ x := +theorem algEquivOfEqComap_apply (h : P = Q.comap σ) (x : B) : + algEquivOfEqComap p σ h (Ideal.Quotient.mk P x) = σ x := rfl end algEquiv @@ -333,7 +335,7 @@ def stabilizerHom : MulAction.stabilizer G P →* ((B ⧸ P) ≃ₐ[A ⧸ p] (B exact congrArg (Ideal.Quotient.mk P) (mul_smul g h x) @[simp] theorem stabilizerHom_apply (g : MulAction.stabilizer G P) (b : B) : - stabilizerHom P p G g b = ↑(g • b) := + stabilizerHom P p G g (Ideal.Quotient.mk P b) = ↑(g • b) := rfl lemma ker_stabilizerHom : diff --git a/Mathlib/RingTheory/Ideal/Quotient/Operations.lean b/Mathlib/RingTheory/Ideal/Quotient/Operations.lean index 8a5d73d16743ff..cee1263ebf3f8e 100644 --- a/Mathlib/RingTheory/Ideal/Quotient/Operations.lean +++ b/Mathlib/RingTheory/Ideal/Quotient/Operations.lean @@ -720,7 +720,7 @@ lemma quotientEquivAlg_symm (f : A ≃ₐ[R₁] B) (hIJ : J = I.map (f : A →+* @[simp] lemma quotientEquivAlg_mk (f : A ≃ₐ[R₁] B) (hIJ : J = I.map (f : A →+* B)) (x : A) : - Ideal.quotientEquivAlg I J f hIJ x = f x := + Ideal.quotientEquivAlg I J f hIJ (Ideal.Quotient.mk I x) = f x := rfl end diff --git a/Mathlib/RingTheory/MvPolynomial/Localization.lean b/Mathlib/RingTheory/MvPolynomial/Localization.lean index 35c22a0cdc56ac..7bf60ab9f64d7b 100644 --- a/Mathlib/RingTheory/MvPolynomial/Localization.lean +++ b/Mathlib/RingTheory/MvPolynomial/Localization.lean @@ -78,7 +78,8 @@ def auxHom : (MvPolynomial Unit R) ⧸ (Ideal.span { C r * X () - 1 }) →ₐ[R] @[simp] private lemma auxHom_mk (p : MvPolynomial Unit R) : - auxHom S r p = aeval (S₁ := S) (fun _ ↦ invSelf r) p := + auxHom S r (Ideal.Quotient.mk (Ideal.span {C r * X () - 1}) p) = + aeval (S₁ := S) (fun _ ↦ invSelf r) p := rfl set_option backward.privateInPublic true in diff --git a/Mathlib/RingTheory/Smooth/Kaehler.lean b/Mathlib/RingTheory/Smooth/Kaehler.lean index e040e772d8cdc3..0d8a9635c9215a 100644 --- a/Mathlib/RingTheory/Smooth/Kaehler.lean +++ b/Mathlib/RingTheory/Smooth/Kaehler.lean @@ -271,7 +271,8 @@ def derivationQuotKerSq : @[simp] lemma derivationQuotKerSq_mk (x : P) : - derivationQuotKerSq R P S x = 1 ⊗ₜ .D R P x := rfl + derivationQuotKerSq R P S (Ideal.Quotient.mk (RingHom.ker (algebraMap P S) ^ 2) x) = + 1 ⊗ₜ .D R P x := rfl set_option linter.flexible false in variable (R P S) in @@ -295,18 +296,10 @@ def tensorKaehlerQuotKerSqEquiv : ext a obtain ⟨a, rfl⟩ := Ideal.Quotient.mk_surjective a simp [f₁, f₂, f₃, f₄, f₅] - have hd : - (derivationQuotKerSq R P S) - ((Ideal.Quotient.mk (RingHom.ker (algebraMap P S) ^ 2)) a) = - 1 ⊗ₜ[P] KaehlerDifferential.D R P a := - derivationQuotKerSq_mk (R := R) (P := P) (S := S) a - rw [hd] - simp [KaehlerDifferential.map_D] right_inv := by suffices f₂.comp f₅ = LinearMap.id from LinearMap.congr_fun this ext a - simp [f₁, f₂, f₃, f₄, f₅] - exact derivationQuotKerSq_mk (R := R) (P := P) (S := S) a } + simp [f₁, f₂, f₃, f₄, f₅] } @[simp] lemma tensorKaehlerQuotKerSqEquiv_tmul_D (s t) : diff --git a/Mathlib/RingTheory/TensorProduct/Quotient.lean b/Mathlib/RingTheory/TensorProduct/Quotient.lean index b3449066019b68..f2db5f5444f2a5 100644 --- a/Mathlib/RingTheory/TensorProduct/Quotient.lean +++ b/Mathlib/RingTheory/TensorProduct/Quotient.lean @@ -113,12 +113,14 @@ noncomputable def tensorQuotientEquiv (I : Ideal T) : @[simp] lemma tensorQuotientEquiv_apply_tmul (I : Ideal T) (a : A) (t : T) : - tensorQuotientEquiv (R := R) S T A I (a ⊗ₜ t) = a ⊗ₜ[R] t := + tensorQuotientEquiv (R := R) S T A I (a ⊗ₜ[R] Ideal.Quotient.mk I t) = a ⊗ₜ[R] t := rfl @[simp] lemma tensorQuotientEquiv_symm_apply_tmul (I : Ideal T) (a : A) (t : T) : - (tensorQuotientEquiv (R := R) S T A I).symm (a ⊗ₜ[R] t) = a ⊗ₜ[R] (Ideal.Quotient.mk I t) := + (tensorQuotientEquiv (R := R) S T A I).symm + (Ideal.Quotient.mk (I.map (includeRight (A := A) (R := R))) (a ⊗ₜ[R] t)) = + a ⊗ₜ[R] (Ideal.Quotient.mk I t) := rfl /-- The tensor product over `R` of the quotient of an `S`-algebra `A` by an ideal `I` with `T` @@ -132,12 +134,14 @@ noncomputable def quotientTensorEquiv (I : Ideal A) : @[simp] lemma quotientTensorEquiv_apply_tmul (I : Ideal A) (a : A) (t : T) : - quotientTensorEquiv (R := R) S T A I (a ⊗ₜ t) = a ⊗ₜ[R] t := + quotientTensorEquiv (R := R) S T A I (Ideal.Quotient.mk I a ⊗ₜ[R] t) = a ⊗ₜ[R] t := rfl @[simp] lemma quotientTensorEquiv_symm_apply_tmul (I : Ideal A) (a : A) (t : T) : - (quotientTensorEquiv (R := R) S T A I).symm (a ⊗ₜ[R] t) = Ideal.Quotient.mk _ a ⊗ₜ[R] t := + (quotientTensorEquiv (R := R) S T A I).symm + (Ideal.Quotient.mk (I.map (algebraMap A (A ⊗[R] T))) (a ⊗ₜ[R] t)) = + Ideal.Quotient.mk _ a ⊗ₜ[R] t := rfl end diff --git a/scripts/nolints.json b/scripts/nolints.json index b4182b0f8e132f..55ab758889bf0b 100644 --- a/scripts/nolints.json +++ b/scripts/nolints.json @@ -826,6 +826,7 @@ ["docBlame", "Mathlib.Tactic.Find.findType"], ["docBlame", "Mathlib.Tactic.GCongr.exact"], ["docBlame", "Module.End.Eigenvalues.val"], + ["docBlame", "ModuleCat.MonoidalCategory.instMonoidalSemimoduleCatFunctorEquivalenceSemimoduleCat"], ["docBlame", "Order.Ideal.PrimePair.F"], ["docBlame", "Order.Ideal.PrimePair.I"], ["docBlame", "Mathlib.Command.Variable.variable?.checkRedundant"], From dde7887ebcdc6faa97f9a990920f00b6ef7f543e Mon Sep 17 00:00:00 2001 From: Riccardo Brasca Date: Mon, 25 May 2026 12:30:22 +0200 Subject: [PATCH 30/30] Fix proofs broken by simplification changes --- Mathlib/RingTheory/Ideal/CotangentBaseChange.lean | 8 -------- Mathlib/RingTheory/Invariant/Basic.lean | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Mathlib/RingTheory/Ideal/CotangentBaseChange.lean b/Mathlib/RingTheory/Ideal/CotangentBaseChange.lean index b2ba010bb4b1cb..3906a0f80dd868 100644 --- a/Mathlib/RingTheory/Ideal/CotangentBaseChange.lean +++ b/Mathlib/RingTheory/Ideal/CotangentBaseChange.lean @@ -117,14 +117,6 @@ lemma tensorCotangentHom_injective_of_flat [Module.Flat R T] : obtain ⟨x, rfl⟩ := I.toCotangent_surjective x dsimp [f, g, hₐ] rw [tensorCotangentHom_tmul, one_smul, Ideal.toCotangent_to_quotient_square] - have hq : - (Algebra.TensorProduct.tensorQuotientEquiv T S T (I ^ 2)) - (1 ⊗ₜ[R] (Ideal.Quotient.mk (I ^ 2) (x : S))) = - Ideal.Quotient.mk ((I ^ 2).map - (Algebra.TensorProduct.includeRight : S →ₐ[R] T ⊗[R] S)) (1 ⊗ₜ[R] (x : S)) := by - exact Algebra.TensorProduct.tensorQuotientEquiv_apply_tmul - (R := R) (S := T) (T := S) (A := T) (I := I ^ 2) (a := 1) (t := (x : S)) - rw [hq, Ideal.quotientEquivAlgOfEq_mk] rfl rw [this, LinearMap.coe_comp] apply hₐ.injective.comp diff --git a/Mathlib/RingTheory/Invariant/Basic.lean b/Mathlib/RingTheory/Invariant/Basic.lean index 9b0a358a3754f8..cfc5e19a96a3b1 100644 --- a/Mathlib/RingTheory/Invariant/Basic.lean +++ b/Mathlib/RingTheory/Invariant/Basic.lean @@ -357,7 +357,7 @@ theorem IsFractionRing.stabilizerHom_apply_apply_mk (σ : MulAction.stabilizer G algebraMap _ L (Ideal.Quotient.mk Q (σ.val • x)) := by simp only [IsFractionRing.stabilizerHom, MonoidHom.coe_comp, Function.comp_apply, IsFractionRing.fieldEquivOfAlgEquivHom_apply, IsFractionRing.fieldEquivOfAlgEquiv_algebraMap] - simpa using congrArg (algebraMap (B ⧸ Q) L) + simpa only using congrArg (algebraMap (B ⧸ Q) L) (Ideal.Quotient.stabilizerHom_apply (P := Q) (p := P) (G := G) σ x) /-- This theorem will be made redundant by `IsFractionRing.stabilizerHom_surjective`. -/