Skip to content

Commit

Permalink
chore: demote charZero_of_expChar_one' instance to a theorem (#7777)
Browse files Browse the repository at this point in the history
The low-priority instance `charZero_of_expChar_one'` takes as an input a `Nontrivial R` and a `ExpChar R 1` instance, but there are no such `ExpChar` instances in Mathlib. It is tried before `StrictOrderedSemiring.to_charZero` when synthesizing `CharZero Nat`, and the former takes a long time to fail (~100ms) because Lean tries to construct `Nontrivial Nat` in all possible ways before giving up, for some reason. See [Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Regression.20in.20simp) and [the synthInstance trace](https://gist.github.com/collares/8590a08c79eed16879a823233b03ba70) for context.




Co-authored-by: Mario Carneiro <di.gama@gmail.com>
  • Loading branch information
collares and digama0 committed Nov 1, 2023
1 parent 9a7e2f0 commit bc2e279
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Mathlib/Algebra/CharP/ExpChar.lean
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ theorem char_zero_of_expChar_one (p : ℕ) [hp : CharP R p] [hq : ExpChar R 1] :
· exact False.elim (CharP.char_ne_one R 1 rfl)
#align char_zero_of_exp_char_one char_zero_of_expChar_one

-- see Note [lower instance priority]
-- This could be an instance, but there are no `ExpChar R 1` instances in mathlib.
/-- The characteristic is zero if the exponential characteristic is one. -/
instance (priority := 100) charZero_of_expChar_one' [hq : ExpChar R 1] : CharZero R := by
theorem charZero_of_expChar_one' [hq : ExpChar R 1] : CharZero R := by
cases hq
· assumption
· exact False.elim (CharP.char_ne_one R 1 rfl)
Expand Down

0 comments on commit bc2e279

Please sign in to comment.