Zulip Chat Archive

Stream: Is there code for X?

Topic: Tactic for proving simple inequalities (in ℕ∞)


Lessness (Oct 28 2023 at 22:44):

I'm trying to prove that from H1: a <= 1 and H2: b <= 1 the goal a+b<=2 follows.
For now I'm not very successful. :sweat_smile:

Which tactic should I use?

Lessness (Oct 28 2023 at 22:44):

I've heard that Omega isn't ready yet, but maybe there is something less powerful?

Kevin Buzzard (Oct 28 2023 at 22:44):

linarith

Lessness (Oct 28 2023 at 23:14):

Oh, those were ℕ∞, not Nat. That explains much.

Lessness (Oct 29 2023 at 09:48):

I have such goal, caused by my choice to use encard:

S1: Set V
S2: Set V
T1: Set V
T2: Set V
H7: Set.encard S1  Set.encard T1
H8: Set.encard S2  Set.encard T2
H9: Set.encard T1  1
H10: Set.encard T2  1
 Set.encard S1 + Set.encard S2  2

Any suggestions?

Damiano Testa (Oct 29 2023 at 11:30):

Does apply (add_le_add H7 H8).trans work?

Lessness (Oct 29 2023 at 11:35):

Ooo, yes! It changes the goal to Set.encard T1 + Set.encard T2 ≤ 2

Damiano Testa (Oct 29 2023 at 11:49):

So, one more step and you should get to 1 + 1 ≤ 2!

Lessness (Oct 29 2023 at 11:53):

Thank you very much! :)
Yes, it's done.

Lessness (Oct 29 2023 at 19:17):

(I will put this here, too, to avoid too many topics.)
How can I prove this? Thanks in advance.

neighbors: Set V
H0: Set.encard neighbors  2
 Set.encard neighbors = 0  Set.encard neighbors = 1  Set.encard neighbors = 2

Ruben Van de Velde (Oct 29 2023 at 19:29):

Does fin_cases Set.encard neighbors <;> simp work? Probably not in ℕ∞

Lessness (Oct 29 2023 at 19:38):

Right now it causes error unexpected syntax. Do I need to import something?

Ruben Van de Velde (Oct 29 2023 at 19:39):

Mathlib.Tactic.FinCases

Lessness (Oct 29 2023 at 20:11):

Still unexpected syntax, at least for me. It seems that it isn't working, not with ℕ∞ :(

Lessness (Oct 30 2023 at 09:21):

I almost proved it, using theorem Set.encard_le_coe_iff, but I still have one sorry.

import Mathlib

def test (w: Nat) (h: w  2): w = 0  w = 1  w = 2 := by
  linarith
  sorry

Here linarith does not want to work. :| Any suggestions?

Lessness (Oct 30 2023 at 09:26):

For now I proved it by destructing w enough times.

Shreyas Srinivas (Oct 30 2023 at 09:40):

import Mathlib.Tactic

theorem test (w: Nat) (h: w  2): w = 0  w = 1  w = 2 := by
  interval_cases w
  ·  left; rfl;
  ·  right;left;rfl;
  ·  right;right;rfl;
  done

Shreyas Srinivas (Oct 30 2023 at 09:42):

Much shorter:

import Mathlib.Tactic

theorem test (w: Nat) (h: w  2): w = 0  w = 1  w = 2 := by
  interval_cases w <;> simp only
  done

Shreyas Srinivas (Oct 30 2023 at 09:45):

A third option which uses tauto:

import Mathlib.Tactic

theorem test (w: Nat) (h: w  2): w = 0  w = 1  w = 2 := by
  interval_cases w <;> tauto
  done

Ruben Van de Velde (Oct 30 2023 at 10:26):

Oh duh, I was thinking of interval_cases, not fin_cases. Sorry for the confusion

Lessness (Oct 30 2023 at 17:01):

Thank you!


Last updated: Dec 20 2023 at 11:08 UTC