Zulip Chat Archive

Stream: mathlib4

Topic: rw? not closing goal


Patrick Massot (Sep 18 2023 at 14:00):

There is an inconsistency between apply? and rw? when the first suggestion closes the goal.

import Mathlib.Tactic
import Mathlib.Data.Real.Basic

example (x : ) (h : 0 < x) : |x| = x := by -- no error
  apply?

example (x : ) (h : 0 < x) : |x| = x := by -- unsolved goal
  rw?

I prefer the apply? behavior because i leave those tactics in my lecture notes when I want to point out there is no need to remember a lemma name.

Patrick Massot (Sep 18 2023 at 14:00):

@Scott Morrison

Patrick Massot (Sep 18 2023 at 14:01):

Wait, my example isn't good.

Patrick Massot (Sep 18 2023 at 14:01):

I meant to write an example where there is no remaining goal at all.

Patrick Massot (Sep 18 2023 at 14:02):

import Mathlib.Tactic
import Mathlib.Data.Real.Basic

example (x y : )  : x + y = y + x := by -- no error
  apply?

example (x y : ) : x + y = y + x := by -- unsolved goal
  rw?

is what I meant

Scott Morrison (Sep 18 2023 at 23:37):

This is currently rw?!. I guess there is no harm in just making it the default.

Scott Morrison (Sep 18 2023 at 23:44):

@Patrick Massot, #7247

Patrick Massot (Sep 19 2023 at 00:06):

Thanks!

Antoine Chambert-Loir (Sep 19 2023 at 10:08):

There are also moments where I want to do some rewrite. My strategy then is to construct an example which asserts the equality and to search for a proof using apply?. But very often, its answer is rfl and I'm stuck in my ignorance.

Scott Morrison (Sep 19 2023 at 11:28):

@Antoine Chambert-Loir, doesn't rw? solve this problem for you? It won't ever say rfl. It's also often easy to use because you don't need to "isolate" the fact you know you need.

Antoine Chambert-Loir (Sep 19 2023 at 11:35):

I'm not sure I ever tried that… I'll try next time, thanks for the hint!

Ruben Van de Velde (Sep 19 2023 at 11:40):

Yeah, I also use it for this purpose. (Though it would be nice if apply? didn't insist on suggesting rfl so much)

Scott Morrison (Sep 19 2023 at 11:41):

The hooks are all there in solve_by_elim to reject that solution!

Scott Morrison (Sep 19 2023 at 11:41):

(Although I do plan to rewrite all those hooks in the new future, so maybe it is best not to learn/use them right now. :-)


Last updated: Dec 20 2023 at 11:08 UTC