Zulip Chat Archive

Stream: lean4

Topic: apply? tactic fails?


DogaCanSertbas (Sep 06 2023 at 09:04):

In LFTCM2023, we had a problem related to "apply?" tactic. More precisely, after writing the "apply?" tactic, it gave several suggestions. However, after doing the corresponding replacement, say "refine Iff.mpr mem_lowerBounds ?h.a", then LEAN failed to continue. Thanks to Eric Wieser, he suggested to rewrite "refine Iff.mpr mem_lowerBounds ?h.aa" which solved the problem. It seems that it is a bug

Bhavik Mehta (Sep 06 2023 at 09:08):

(I am in the process of minimising the example for Doga)

Martin Dvořák (Sep 06 2023 at 09:09):

On a related note, has the output of apply? ever been useful for you?

Martin Dvořák (Sep 06 2023 at 09:10):

I am not attempting to criticize the tactic. I just want to know whether I should keep trying to make use of it.

Bhavik Mehta (Sep 06 2023 at 09:11):

In this actual case the third result of apply? was a sensible suggestion (although rw? finds the same correct lemma as its first suggestion, and avoids the Iff.mpr at the start). So I suppose it was useful but not as useful as rw? would have been

DogaCanSertbas (Sep 06 2023 at 09:12):

Martin Dvořák dedi:

On a related note, has the output of apply? ever been useful for you?

As a beginner, I can say yes :)

Martin Dvořák (Sep 06 2023 at 09:13):

I am happy to hear about it!

Martin Dvořák (Sep 06 2023 at 09:14):

Speaking of beginners, it took me almost two years to learn what the .mpr thing means, lol.

Bhavik Mehta (Sep 06 2023 at 09:32):

I'm struggling to get it more minimised, so here's my progress so far in case someone else can take it further:

import Mathlib.Data.Real.Basic

noncomputable def bad_definition :  :=  (n : ) (_ : 1  n), 1 / n

theorem failure : bad_definition  1 := by
  apply ciInf_le_of_le _ 1
  · apply ciInf_le_of_le _ le_rfl
    · sorry
    · use 0
      refine Iff.mpr mem_lowerBounds ?h.a
      sorry
  · use 0
    apply?

Alex J. Best (Sep 06 2023 at 11:33):

I'm not sure exactly what the correct fix is yet, but here is a more minimal example with the same behaviour (though in this case you could say that axiom f is written badly)

import Mathlib.Tactic.LibrarySearch

axiom T : (a : Nat)  Prop
axiom f (a : Nat) : (h : T (3 * a))  (h : T (2 * a))  T a
example (b : Nat) : T b := by
  apply f
  apply f
  sorry
  apply?

Bhavik Mehta (Sep 06 2023 at 15:59):

Would it work to have two axioms which both use the name h, so it's not attributable to bad naming of a single thing?


Last updated: Dec 20 2023 at 11:08 UTC