Zulip Chat Archive
Stream: new members
Topic: noncomm_ring simp lemmas don't apply
Darij Grinberg (Oct 27 2025 at 19:10):
Someone here is going along with an example I'm showing on my machine, which works on my machine, but for some reason doesn't on theirs. It's the noncomm_ring tactic saying that noncomm_ring simp lemmas don't apply. This happens for them even if they're trying to prove that a + b = b + a for integers a and b. Is there a known bug?
Kevin Buzzard (Oct 27 2025 at 22:33):
If it works on one machine and not another, then my first conjecture would be that those machines are using different versions of mathlib, and whoever is having problems should try updating. What is the error? This would be a helpful thing to report.
Darij Grinberg (Oct 27 2025 at 23:01):
I'll ask her tomorrow. For now I recall the message suggested using abel isntead.
Darij Grinberg (Oct 27 2025 at 23:02):
hmm, maybe it was failing to find the second operation
Darij Grinberg (Oct 29 2025 at 19:08):
Darij Grinberg (Oct 29 2025 at 19:08):
This is the error she's getting
Darij Grinberg (Oct 29 2025 at 19:09):
4.21.0
Darij Grinberg (Oct 29 2025 at 19:09):
but she also gets it for simpler things like proving a + b = b + a for a, b \in \Z
Darij Grinberg (Oct 29 2025 at 19:09):
this is not a Nat/Int issue
Aaron Liu (Oct 29 2025 at 19:10):
can reproduce
import Mathlib
-- `noncomm_ring` simp lemmas don't apply; try `abel` instead
example (a b : ℤ) : a + b = b + a := by noncomm_ring
Aaron Liu (Oct 29 2025 at 19:13):
I think the intent here is that you use abel instead
Darij Grinberg (Oct 29 2025 at 19:14):
prolly, but I'm scared by the nondeterminism of it all
Darij Grinberg (Oct 29 2025 at 19:14):
for me it works and i'm on 4.21.0 too
Aaron Liu (Oct 29 2025 at 19:14):
maybe it's a different commit of mathlib
Darij Grinberg (Oct 29 2025 at 19:19):
I see. So #version tells you a round number even if you're on a nightly :)
Aaron Liu (Oct 29 2025 at 19:20):
#version gives you the Lean version, but maybe it's on a different version of mathlib
Darij Grinberg (Oct 29 2025 at 19:23):
oh!
Kenny Lau (Oct 29 2025 at 19:23):
is there a #version mathlib?
Kevin Buzzard (Oct 29 2025 at 20:43):
mathlib doesn't have releases so you may as well just do git log.
Kevin Buzzard (Oct 29 2025 at 20:44):
I guess one thing to add here is that the naturals are not a non-commutative ring ;-)
Darij Grinberg (Oct 29 2025 at 20:50):
Yeah, I guess semiring would fit better... but I guess it's not explaining why it's failing for \Z
Kevin Buzzard (Oct 29 2025 at 21:04):
This also fails with the same error:
import Mathlib
example (R : Type) [Ring R] (a b : R) : a + b = b + a := by
noncomm_ring
At this point I am thinking that this is unexpected behaviour and you might want to open an issue. Or perhaps the designers are well aware of this issue and are arguing that because you are not using multiplication at all you're using the wrong tactic anyway and should be using the abelian group tactic.
Aaron Liu (Oct 29 2025 at 21:06):
yes that's how I interpreted it
Darij Grinberg (Oct 30 2025 at 02:09):
And this seems to be true. Quoting my collaborator: "That makes sense. I didn't update Mathlib, but after rewriting the equation as 1a+1b = 1b+1a, noncomm_ring works now."
Darij Grinberg (Oct 30 2025 at 02:10):
I must say I was rather surprised that a tactic(!) is defined in mathlib rather than in Lean proper. But I guess this is what you get when tactics are so easy to define :)
Aaron Liu (Oct 30 2025 at 02:11):
rings are defined in mathlib (well I guess now that we have grind they're also defined in core)
Robin Arnez (Nov 01 2025 at 20:50):
I guess it'd be even more surprising to you then that in fact the majority of tactics don't come from core (253 from core, 266 directly from mathlib, 39 from a dependency of mathlib)
Last updated: Dec 20 2025 at 21:32 UTC