Zulip Chat Archive

Stream: new members

Topic: Why can't linarith prove this goal


Timothy Mou (Feb 21 2024 at 00:46):

Why can't linarith prove this goal:

example (i n : ) : i < n + 1  ¬ (i = n)  i < n := by
  linarith

Timothy Mou (Feb 21 2024 at 00:52):

What tactic should I use for linear integer arithmetic?

Matthew Ballard (Feb 21 2024 at 00:53):

Another option is omega

Timothy Mou (Feb 21 2024 at 01:01):

Thanks. It's a bit hard to search for this stuff, and I incorrectly assumed linarith was the analogue of Coq's lia

Matthew Ballard (Feb 21 2024 at 01:11):

I would think linarithshould do this also.

Matthew Ballard (Feb 21 2024 at 01:12):

omega seems (is?) much more recent so documentation needs to catch up

Kyle Miller (Feb 21 2024 at 01:34):

though linarith doesn't know about the fact that there are no natural numbers between n and n + 1

Patrick Massot (Feb 21 2024 at 02:30):

Kyle, this isn’t the issue. There are two completely independent issues. First linarith doesn’t do intro, this is simply not its job. And, for performance reasons, it doesn’t split not equal assumptions into two inequalities cases (since this could lead to a huge number of cases). So you can get a proof with:

Patrick Massot (Feb 21 2024 at 02:30):

example (i n : ) : i < n + 1  ¬ (i = n)  i < n := by
  intro h₁ h₂
  linarith (config := {splitNe := true})

Patrick Massot (Feb 21 2024 at 02:31):

To be honest I was never really convinced by the argument in favor of the splitNe := false default.

Patrick Massot (Feb 21 2024 at 02:34):

And I think the way linarith “knows” there is no natural number between n and n+1 is simply by preprocessing the inequality i < n into i + 1 ≤ n.


Last updated: May 02 2025 at 03:31 UTC