Zulip Chat Archive

Stream: new members

Topic: Tactic for range analysis over the Naturals


Elizaveta Pertseva (Jul 14 2025 at 20:43):

Hello! Is there a tactic that performs range analysis over the naturals? For example is there a tactic that could automatically deduce the following lemma?

lemma bound {x y : } (hx : x <= 1) (hy : y <= 1) :
  (1 - x) * y + x * (1 - y)  1 := by

linarith fails. Thank you so much for your help!

Kenny Lau (Jul 14 2025 at 20:49):

import Mathlib

lemma bound {x y : } (hx : x  1) (hy : y  1) :
    (1 - x) * y + x * (1 - y)  1 := by
  interval_cases x <;> interval_cases y <;> decide

lemma bound' {x y : } (hx : x  1) (hy : y  1) :
    (1 - x) * y + x * (1 - y)  1 := by
  revert x; revert y; decide

Elizaveta Pertseva (Jul 14 2025 at 21:03):

Thank you! interval_cases really helps, but I am likely to have more complex expressions with a lot of variables so I was hoping there was a tactic that did this under the hood.

Kenny Lau (Jul 14 2025 at 21:05):

if x is not a variable then you would need to generalize it first


Last updated: Dec 20 2025 at 21:32 UTC