Zulip Chat Archive
Stream: new members
Topic: ring tactic in the field of rationals
JK (Aug 04 2025 at 00:20):
I'm a bit confused by the following simple example that works in Lean:
example (w : ℚ) (h : 3*w + 1 = 4) :
w = 1 :=
calc
w = (3 * w + 1) / 3 - 1/3 := by ring
_ = 4/3 - 1/3 := by rw [h]
_ = 1 := by ring
How does the ring tactic "know" about division? (I understand that the rationals are a field ... but I would expect to have to use a "field tactic" to take advantage of that fact.)
Eric Wieser (Aug 04 2025 at 00:22):
ring is using norm_num
Eric Wieser (Aug 04 2025 at 00:22):
It doesn't know about division by variables, only by numeric constants
Eric Wieser (Aug 04 2025 at 00:25):
For a similar reason, ring knows about Nat.factorial!
import Mathlib
example {R} [CommRing R] {a : R} : Nat.factorial 3 * a = a + a + a + a + a + a := by
ring
JK (Aug 04 2025 at 00:34):
That's still odd to me, since (3 * w + 1) / 3 is not defined in an arbitrary ring, nor is 1/3 for that matter.
Eric Wieser (Aug 04 2025 at 00:37):
I guess it's probably more accurate to say that ring knows about -algebras
Aaron Liu (Aug 04 2025 at 00:37):
commutative ones
Last updated: Dec 20 2025 at 21:32 UTC