Zulip Chat Archive

Stream: new members

Topic: Finset.Icc on Z


Junjie Bai (Mar 28 2024 at 13:54):

How can I prove the second 'have' part is ture on Z? I can't push forward my prove any more. :-(

theorem sub_of_sum (a : ) (f :   ) (h : 1  a):  x in Icc 1 (a + 1), f x -  x in Icc 1 a, f x = f (a + 1) := by
  have hncons : (a + 1)  Finset.Icc 1 a := by simp
  have hcons : (Finset.Icc 1 (a + 1)) = cons (a + 1) (Finset.Icc 1 a) hncons := by
    simp
    sorry
  rw [hcons]
  rw [sum_cons]
  simp

Damiano Testa (Mar 28 2024 at 16:05):

This works:

  have hcons : (Finset.Icc 1 (a + 1)) = cons (a + 1) (Finset.Icc 1 a) hncons := by
    ext n
    rw [mem_Icc, cons_eq_insert, mem_insert, mem_Icc]
    omega

Eric Wieser (Mar 28 2024 at 16:17):

I would guess you can use mem_cons to use one fewer lemma

Damiano Testa (Mar 28 2024 at 16:18):

Indeed!

  have hcons : (Finset.Icc 1 (a + 1)) = cons (a + 1) (Finset.Icc 1 a) hncons := by
    ext n
    rw [mem_Icc, mem_cons, mem_Icc]
    omega

Damiano Testa (Mar 28 2024 at 16:19):

Did you know that this was a possibility?

  have hcons : (Finset.Icc 1 (a + 1)) = cons (a + 1) (Finset.Icc 1 a) hncons := by
    ext n
    simpa using (by omega)

Junjie Bai (Mar 29 2024 at 05:50):

I learned a lot from it! Thanks a lot!

Floris van Doorn (Mar 29 2024 at 08:36):

Damiano Testa said:

Did you know that this was a possibility?

  have hcons : (Finset.Icc 1 (a + 1)) = cons (a + 1) (Finset.Icc 1 a) hncons := by
    ext n
    simpa using (by omega)

Presumably that does the same as simp; omega?

Damiano Testa (Mar 29 2024 at 08:37):

Yes, it is the same, at least in this case. I wonder if using it systematically might be a good way of "avoiding" non-terminal simps...

Damiano Testa (Mar 29 2024 at 08:37):

(Of course, limiting the tactics that can be used in that position)

Floris van Doorn (Mar 29 2024 at 08:40):

I think that simp; omega should just be allowed. If simp simplifies slightly differently, omega is still likely to finish the goal.

Yaël Dillies (Mar 29 2024 at 08:41):

I think using weird syntax to avoid non-terminal simp (which is something we have decided is bad) would be stupid

Damiano Testa (Mar 29 2024 at 08:42):

Ok, I'm making progress on the new version of the non-terminal simp linter and was indeed planning to go with the allowed followers approach.

Damiano Testa (Mar 29 2024 at 08:43):

(or rather, rigid tactics cannot follow flexible ones)


Last updated: May 02 2025 at 03:31 UTC