Zulip Chat Archive

Stream: general

Topic: Why can't linarith do simple association here?


Sophia C (Jul 17 2024 at 02:38):

So, I'm playing around with Lean, and I'm trying to prove a simple theorem:

{z : } : 4*z + (4 - 1) = (4*z + 4) - 1

and I can't seem to do it with linarith alone.

Yury G. Kudryashov (Jul 17 2024 at 02:40):

Short answer: try omega. Long answer: probably, linarith doesn't split nat subtraction into cases.

Yury G. Kudryashov (Jul 17 2024 at 02:41):

You can also try to zify and see if it can push Nat.cast (_ - _) to Nat.cast _ - Nat.cast _.

Yury G. Kudryashov (Jul 17 2024 at 02:41):

The issue is that (2 - 3 : Nat) = 0 in Lean/Mathlib, so a + (b - c) = (a + b) - c requires c ≤ b.

James Sully (Jul 17 2024 at 14:23):

that one's true by rfl


Last updated: May 02 2025 at 03:31 UTC