Skip to content

Commit ef2abb0

Browse files
committed
chore: use more inferInstanceAs (#37315)
Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
1 parent 4703502 commit ef2abb0

File tree

10 files changed

+35
-28
lines changed

10 files changed

+35
-28
lines changed

Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ protected def coe (r : ℝ) : Angle := QuotientAddGroup.mk r
4141
instance : Coe ℝ Angle := ⟨Angle.coe⟩
4242

4343
instance : CircularOrder Real.Angle :=
44-
QuotientAddGroup.circularOrder (hp' := ⟨by simp [pi_pos]⟩)
44+
fast_instance% QuotientAddGroup.circularOrder (hp' := ⟨by simp [pi_pos]⟩)
4545

46-
47-
@[continuity]
46+
@[continuity, fun_prop]
4847
theorem continuous_coe : Continuous ((↑) : ℝ → Angle) :=
4948
continuous_quotient_mk'
5049

Mathlib/Combinatorics/SimpleGraph/Connectivity/Finite.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ instance : DecidableRel G.Reachable := fun u v =>
5757
decidable_of_iff' _ (reachable_iff_exists_finsetWalkLength_nonempty G u v)
5858

5959
instance : Fintype G.ConnectedComponent :=
60-
@Quotient.fintype _ _ G.reachableSetoid (inferInstance : DecidableRel G.Reachable)
60+
fast_instance% @Quotient.fintype _ _ G.reachableSetoid (inferInstance : DecidableRel G.Reachable)
6161

6262
instance : Decidable G.Preconnected :=
6363
inferInstanceAs <| Decidable (∀ u v, G.Reachable u v)

Mathlib/Combinatorics/SimpleGraph/EdgeLabeling.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def EdgeLabeling (G : SimpleGraph V) (K : Type*) :=
3838
G.edgeSet → K
3939

4040
instance [DecidableEq V] [Fintype G.edgeSet] [Fintype K] : Fintype (EdgeLabeling G K) :=
41-
Pi.instFintype
41+
inferInstanceAs <| Fintype (G.edgeSet → K)
4242

4343
instance [Finite G.edgeSet] [Finite K] : Finite (EdgeLabeling G K) :=
4444
Pi.finite
@@ -47,7 +47,7 @@ instance [Nonempty K] : Nonempty (EdgeLabeling G K) :=
4747
Pi.instNonempty
4848

4949
instance [Inhabited K] : Inhabited (EdgeLabeling G K) :=
50-
Pi.instInhabited
50+
inferInstanceAs <| Inhabited (G.edgeSet → K)
5151

5252
instance [Subsingleton K] : Subsingleton (EdgeLabeling G K) :=
5353
Pi.instSubsingleton
@@ -56,7 +56,7 @@ instance [Nonempty G.edgeSet] [Nontrivial K] : Nontrivial (EdgeLabeling G K) :=
5656
Function.nontrivial
5757

5858
instance [Unique K] : Unique (EdgeLabeling G K) :=
59-
Pi.unique
59+
inferInstanceAs <| Unique (G.edgeSet → K)
6060

6161
/--
6262
An edge labeling of the complete graph on `V` with labels in type `K`.

Mathlib/Combinatorics/SimpleGraph/Walks/Counting.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ instance fintypeSetWalkLength (u v : V) (n : ℕ) : Fintype {p : G.Walk u v | p.
125125
rw [← Finset.mem_coe, coe_finsetWalkLength_eq]
126126

127127
instance fintypeSubtypeWalkLength (u v : V) (n : ℕ) : Fintype {p : G.Walk u v // p.length = n} :=
128-
fintypeSetWalkLength G u v n
128+
inferInstanceAs <| Fintype {p : G.Walk u v | p.length = n}
129129

130130
theorem set_walk_length_toFinset_eq (n : ℕ) (u v : V) :
131131
{p : G.Walk u v | p.length = n}.toFinset = G.finsetWalkLength n u v := by
@@ -143,7 +143,7 @@ instance fintypeSetWalkLengthLT (u v : V) (n : ℕ) : Fintype {p : G.Walk u v |
143143
rw [← Finset.mem_coe, coe_finsetWalkLengthLT_eq]
144144

145145
instance fintypeSubtypeWalkLengthLT (u v : V) (n : ℕ) : Fintype {p : G.Walk u v // p.length < n} :=
146-
fintypeSetWalkLengthLT G u v n
146+
inferInstanceAs <| Fintype {p : G.Walk u v | p.length < n}
147147

148148
instance fintypeSetPathLength (u v : V) (n : ℕ) :
149149
Fintype {p : G.Walk u v | p.IsPath ∧ p.length = n} :=
@@ -152,7 +152,7 @@ instance fintypeSetPathLength (u v : V) (n : ℕ) :
152152

153153
instance fintypeSubtypePathLength (u v : V) (n : ℕ) :
154154
Fintype {p : G.Walk u v // p.IsPath ∧ p.length = n} :=
155-
fintypeSetPathLength G u v n
155+
inferInstanceAs <| Fintype {p : G.Walk u v | p.IsPath ∧ p.length = n}
156156

157157
instance fintypeSetPathLengthLT (u v : V) (n : ℕ) :
158158
Fintype {p : G.Walk u v | p.IsPath ∧ p.length < n} :=
@@ -161,7 +161,7 @@ instance fintypeSetPathLengthLT (u v : V) (n : ℕ) :
161161

162162
instance fintypeSubtypePathLengthLT (u v : V) (n : ℕ) :
163163
Fintype {p : G.Walk u v // p.IsPath ∧ p.length < n} :=
164-
fintypeSetPathLengthLT G u v n
164+
inferInstanceAs <| Fintype {p : G.Walk u v | p.IsPath ∧ p.length < n}
165165

166166
end LocallyFinite
167167

Mathlib/Computability/Language.lean

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,13 @@ variable {α β γ : Type*}
6464
/-- A language is a set of strings over an alphabet. -/
6565
def Language (α) :=
6666
Set (List α)
67+
deriving CompleteAtomicBooleanAlgebra
6768

6869
namespace Language
6970

7071
instance : Membership (List α) (Language α) := ⟨Set.Mem⟩
7172
instance : Singleton (List α) (Language α) := ⟨Set.singleton⟩
7273
instance : Insert (List α) (Language α) := ⟨Set.insert⟩
73-
instance instCompleteAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra (Language α) :=
74-
Set.instCompleteAtomicBooleanAlgebra
7574

7675
variable {l m : Language α} {a b x : List α}
7776

@@ -409,8 +408,8 @@ lemma reverse_kstar (l : Language α) : l∗.reverse = l.reverse∗ := by
409408
lemma mem_inf {x : List α} {l m : Language α} : x ∈ l ⊓ m ↔ x ∈ l ∧ x ∈ m := by
410409
apply Set.mem_inter_iff
411410

412-
lemma compl_compl (l : Language α) : lᶜᶜ = l := by
413-
simp [compl]
411+
lemma compl_compl (l : Language α) : lᶜᶜ = l :=
412+
_root_.compl_compl l
414413

415414
end Language
416415

Mathlib/Data/Fintype/Vector.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ open List (Vector)
1919
variable {α : Type*}
2020

2121
instance Vector.fintype [Fintype α] {n : ℕ} : Fintype (List.Vector α n) :=
22-
Fintype.ofEquiv _ (Equiv.vectorEquivFin _ _).symm
22+
fast_instance% Fintype.ofEquiv _ (Equiv.vectorEquivFin _ _).symm
2323

2424
instance [DecidableEq α] [Fintype α] {n : ℕ} : Fintype (Sym.Sym' α n) :=
25-
Quotient.fintype _
25+
inferInstanceAs <| Fintype (Quotient _)
2626

2727
instance [DecidableEq α] [Fintype α] {n : ℕ} : Fintype (Sym α n) :=
28-
Fintype.ofEquiv _ Sym.symEquivSym'.symm
28+
fast_instance% Fintype.ofEquiv _ Sym.symEquivSym'.symm

Mathlib/Data/Fintype/WithTopBot.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ variable {α : Type*}
1818

1919
@[to_dual]
2020
instance [Fintype α] : Fintype (WithTop α) :=
21-
instFintypeOption
21+
inferInstanceAs <| Fintype (Option α)
2222

2323
@[to_dual]
2424
instance [Finite α] : Finite (WithTop α) :=

Mathlib/Data/Holor.lean

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,30 @@ instance [Add α] : Add (Holor α ds) :=
101101
instance [Neg α] : Neg (Holor α ds) :=
102102
fun a t => -a t⟩
103103

104-
instance [AddSemigroup α] : AddSemigroup (Holor α ds) := Pi.addSemigroup
104+
instance [AddSemigroup α] : AddSemigroup (Holor α ds) :=
105+
inferInstanceAs <| AddSemigroup (HolorIndex ds → α)
105106

106-
instance [AddCommSemigroup α] : AddCommSemigroup (Holor α ds) := Pi.addCommSemigroup
107+
instance [AddCommSemigroup α] : AddCommSemigroup (Holor α ds) :=
108+
inferInstanceAs <| AddCommSemigroup (HolorIndex ds → α)
107109

108-
instance [AddMonoid α] : AddMonoid (Holor α ds) := Pi.addMonoid
110+
instance [AddMonoid α] : AddMonoid (Holor α ds) :=
111+
inferInstanceAs <| AddMonoid (HolorIndex ds → α)
109112

110-
instance [AddCommMonoid α] : AddCommMonoid (Holor α ds) := Pi.addCommMonoid
113+
instance [AddCommMonoid α] : AddCommMonoid (Holor α ds) :=
114+
inferInstanceAs <| AddCommMonoid (HolorIndex ds → α)
111115

112-
instance [AddGroup α] : AddGroup (Holor α ds) := Pi.addGroup
116+
instance [AddGroup α] : AddGroup (Holor α ds) :=
117+
inferInstanceAs <| AddGroup (HolorIndex ds → α)
113118

114-
instance [AddCommGroup α] : AddCommGroup (Holor α ds) := Pi.addCommGroup
119+
instance [AddCommGroup α] : AddCommGroup (Holor α ds) :=
120+
inferInstanceAs <| AddCommGroup (HolorIndex ds → α)
115121

116122
-- scalar product
117123
instance [Mul α] : SMul α (Holor α ds) :=
118124
fun a x => fun t => a * x t⟩
119125

120-
instance [Semiring α] : Module α (Holor α ds) := Pi.module _ _ _
126+
instance [Semiring α] : Module α (Holor α ds) :=
127+
inferInstanceAs <| Module α (HolorIndex ds → α)
121128

122129
/-- The tensor product of two holors. -/
123130
def mul [Mul α] (x : Holor α ds₁) (y : Holor α ds₂) : Holor α (ds₁ ++ ds₂) := fun t =>

Mathlib/Data/PNat/Interval.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ namespace PNat
2424

2525
variable (a b : ℕ+)
2626

27-
instance instLocallyFiniteOrder : LocallyFiniteOrder ℕ+ := Subtype.instLocallyFiniteOrder _
27+
instance instLocallyFiniteOrder : LocallyFiniteOrder ℕ+ :=
28+
inferInstanceAs <| LocallyFiniteOrder (Subtype _)
2829

2930
theorem Icc_eq_finset_subtype : Icc a b = (Icc (a : ℕ) b).subtype fun n : ℕ => 0 < n :=
3031
rfl

Mathlib/Data/Prod/Lex.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public import Mathlib.Order.BoundedOrder.Basic
1010
public import Mathlib.Order.Lattice
1111
public import Mathlib.Order.Lex
1212
public import Mathlib.Tactic.Tauto
13+
public import Mathlib.Tactic.FastInstance
1314

1415
/-!
1516
# Lexicographic order
@@ -146,7 +147,7 @@ instance instPartialOrder (α β : Type*) [PartialOrder α] [PartialOrder β] :
146147
PartialOrder (α ×ₗ β) where
147148
le_antisymm _ _ := antisymm_of (Prod.Lex _ _)
148149

149-
instance instOrdLexProd [Ord α] [Ord β] : Ord (α ×ₗ β) := lexOrd
150+
instance instOrdLexProd [Ord α] [Ord β] : Ord (α ×ₗ β) := fast_instance% lexOrd
150151

151152
theorem compare_def [Ord α] [Ord β] : @compare (α ×ₗ β) _ =
152153
compareLex (compareOn fun x => (ofLex x).1) (compareOn fun x => (ofLex x).2) := rfl

0 commit comments

Comments
 (0)