diff --git a/Mathlib/Algebra/CharP/Basic.lean b/Mathlib/Algebra/CharP/Basic.lean index f4b7930de46e6..a74bdba2f3672 100644 --- a/Mathlib/Algebra/CharP/Basic.lean +++ b/Mathlib/Algebra/CharP/Basic.lean @@ -466,8 +466,9 @@ section NonAssocSemiring variable {R} [NonAssocSemiring R] --- see Note [lower instance priority] -instance (priority := 100) CharOne.subsingleton [CharP R 1] : Subsingleton R := +-- This lemma is not an instance, to make sure that trying to prove `α` is a subsingleton does +-- not try to find a ring structure on `α`, which can be expensive. +lemma CharOne.subsingleton [CharP R 1] : Subsingleton R := Subsingleton.intro <| suffices ∀ r : R, r = 0 from fun a b => show a = b by rw [this a, this b] fun r => @@ -477,8 +478,9 @@ instance (priority := 100) CharOne.subsingleton [CharP R 1] : Subsingleton R := _ = 0 * r := by rw [CharP.cast_eq_zero] _ = 0 := by rw [zero_mul] -theorem false_of_nontrivial_of_char_one [Nontrivial R] [CharP R 1] : False := - false_of_nontrivial_of_subsingleton R +theorem false_of_nontrivial_of_char_one [Nontrivial R] [CharP R 1] : False := by + have : Subsingleton R := CharOne.subsingleton + exact false_of_nontrivial_of_subsingleton R #align char_p.false_of_nontrivial_of_char_one CharP.false_of_nontrivial_of_char_one theorem ringChar_ne_one [Nontrivial R] : ringChar R ≠ 1 := by diff --git a/Mathlib/Data/ZMod/Basic.lean b/Mathlib/Data/ZMod/Basic.lean index ee051be4841e5..8fe8bb4a8a994 100644 --- a/Mathlib/Data/ZMod/Basic.lean +++ b/Mathlib/Data/ZMod/Basic.lean @@ -297,6 +297,7 @@ theorem cast_one (h : m ∣ n) : (cast (1 : ZMod n) : R) = 1 := by cases n; · rw [Nat.dvd_one] at h subst m + have : Subsingleton R := CharP.CharOne.subsingleton apply Subsingleton.elim rw [Nat.mod_eq_of_lt] · exact Nat.cast_one