Skip to content

Commit 5c04ef2

Browse files
committed
chore: adjust Module.Finite instance priority (leanprover-community#37522)
Make instances that are rarely going to be helpful lower priority. Increase the priority of `FiniteDimensional.complexToReal`, because it's more likely correct than the other priority 100 `Module.Finite` instances. Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
1 parent 7131639 commit 5c04ef2

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

Mathlib/LinearAlgebra/Complex/FiniteDimensional.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ theorem finrank_real_complex_fact : Fact (finrank ℝ ℂ = 2) :=
4444

4545
end Complex
4646

47-
instance (priority := 100) FiniteDimensional.complexToReal (E : Type*) [AddCommGroup E]
47+
instance (priority := 500) FiniteDimensional.complexToReal (E : Type*) [AddCommGroup E]
4848
[Module ℂ E] [FiniteDimensional ℂ E] : FiniteDimensional ℝ E :=
4949
FiniteDimensional.trans ℝ ℂ E
5050

Mathlib/LinearAlgebra/Dimension/Free.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ end StrongRankCondition
366366

367367
namespace Algebra
368368

369-
instance (R S : Type*) [CommSemiring R] [StrongRankCondition R] [Semiring S] [Algebra R S]
370-
[IsQuadraticExtension R S] :
369+
instance (priority := 100) (R S : Type*) [CommSemiring R] [StrongRankCondition R] [Semiring S]
370+
[Algebra R S] [IsQuadraticExtension R S] :
371371
Module.Finite R S := finite_of_finrank_eq_succ <| IsQuadraticExtension.finrank_eq_two R S
372372

373373
end Algebra

Mathlib/LinearAlgebra/Dual/Lemmas.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ instance _root_.Prod.instModuleIsReflexive [IsReflexive R N] :
283283
instance _root_.ULift.instModuleIsReflexive.{w} : IsReflexive R (ULift.{w} M) :=
284284
equiv ULift.moduleEquiv.symm
285285

286-
instance instFiniteDimensionalOfIsReflexive (K V : Type*)
286+
-- Very low priority because instance resolution will often end up using the instances above
287+
-- to prove `IsReflexive`, which require proving `Finite` again.
288+
instance (priority := 90) instFiniteDimensionalOfIsReflexive (K V : Type*)
287289
[Field K] [AddCommGroup V] [Module K V] [IsReflexive K V] :
288290
FiniteDimensional K V := by
289291
rw [FiniteDimensional, ← rank_lt_aleph0_iff]

0 commit comments

Comments
 (0)