Zulip Chat Archive

Stream: mathlib4

Topic: Unused simp arguments linter firing wrongly


Michael Stoll (Nov 09 2025 at 21:04):

I just noticed the following. In the example below, the unusedSimpArgs linter complains, but leaving the argument out shows that it is indeed necessary.

import Mathlib

open Nat

/- This simp argument is unused:
  Nat.factorial_ne_zero k -/
example (k : ) : (-1 / k ! : )⁻¹ / k ! = -1 := by
  simp [field, Nat.factorial_ne_zero k]

example (k : ) : (-1 / k ! : )⁻¹ / k ! = -1 := by
  simp [field]
  /- 1 goal left : ↑k ! / ↑k ! = 1 -/
  sorry

/- no warning -/
example (k : ) : (1 / k ! : )⁻¹ / k ! = 1 := by
  simp [field, Nat.factorial_ne_zero k]

/- also works -/
example (k : ) : (-1 / k ! : )⁻¹ / k ! = -1 := by
  simp [field]

The warning goes away when removing the minus signs. A bit surprisingly, when replacing by , the warning is correct. I have no idea what is going on here. @Heather Macbeth ?

Aaron Liu (Nov 09 2025 at 21:06):

this is a known problem

Aaron Liu (Nov 09 2025 at 21:08):

found it #29041

Michael Stoll (Nov 09 2025 at 21:10):

This still does not explain the difference between and , though...

Aaron Liu (Nov 09 2025 at 22:20):

maybe because the reals are ordered?

Michael Stoll (Nov 10 2025 at 10:58):

It should only matter that k ! is nonzero, regardless of the field (as long as it is of char 0).

Heather Macbeth (Nov 10 2025 at 11:02):

The field_simp discharger works a bit differently on  compared to on ordered fields such as . On ordered fields, it uses positivity; on , positivity is not available (although @Floris van Doorn may have a student working on this) and so, for now, we sometimes need lemmas like Nat.factorial_ne_zero to "fake" it.

Damiano Testa (Nov 10 2025 at 11:05):

By the way, here are also a few show_term surprises:

  • it times out on the first proof;
  • shows nothing after a long time on the middle two proofs;
  • works on the last.

Floris van Doorn (Nov 10 2025 at 11:42):

@Pan Lin is indeed working currently working on positivity supporting nonzeroness on non-partial orders.


Last updated: Dec 20 2025 at 21:32 UTC