Zulip Chat Archive

Stream: general

Topic: simp/simpa vs rw/rwa


Damiano Testa (Jan 09 2022 at 03:16):

Could simpa be changed so that if simp closes a goal, then simpa closes it as well, instead of giving an error?
I am thinking of something like rwa which performs the rewrite even when the a(ssumption) is not available.

import tactic

example : 0 = 0 := by simp --works
example : 0 = 0 := by simpa --simpa failed  state: no goals

Maybe there is a reason why this behaviour is unwanted/problematic?

Anne Baanen (Jan 10 2022 at 10:26):

I like this because simpa lets you know when a plain simp would have worked. How about keeping an error or at least a message, but replacing the message with "try this: simp"?

Damiano Testa (Jan 10 2022 at 10:27):

I like the "Try this" idea!

Eric Wieser (Jan 10 2022 at 10:28):

I'd assumed that this thread was going to be the complaint that simpa using foo bar works but rwa [some_lemma] using foo bar doesn't

Damiano Testa (Jan 10 2022 at 10:29):

Ah, I probably named it wrong: i had more an "simp is to simpa as rw is to rwa" in mind.

Johan Commelin (Jan 10 2022 at 10:46):

So there are two improvements: (i) make rwa more like simpa by having rwa ... using .... and (ii) make both of them output Try this: if a rw or simp would already have closed the goal.

Eric Rodriguez (Jan 10 2022 at 10:51):

I'd find rwa usingsuper helpful. I've used simpa only using too many times for that.

Damiano Testa (Jan 10 2022 at 10:52):

Johan, thank you for the more thorough disambiguation: I failed at communication! :face_palm:

Reid Barton (Jan 10 2022 at 13:45):

Isn't rwa using not actually useful though? Isn't rw, exact the same length even?

Filippo A. E. Nuccio (Jan 10 2022 at 13:48):

Well, but you might need rw, exacts which is one character longer :smiley:

Anne Baanen (Jan 10 2022 at 13:48):

If we're following simpa using, rwa [eqs] using hyp would mean something more like have this := hyp, rw [eqs] at this ⊢, exact this

Eric Wieser (Jan 10 2022 at 13:49):

As a compromise, maybe rwa [eqs] using hyp should mean have this := hyp, rw [eqs] at this, exact this (that is, without rewriting at the goal)

Eric Wieser (Jan 10 2022 at 13:50):

Because rw [eqs] at this ⊢ is rarely going to be useful, because every lemma in eqs has to match both this and at every step

Anne Baanen (Jan 10 2022 at 13:51):

Good point, I always forget whether it succeeds if any of the lemmas matches this or all of them.

Reid Barton (Jan 10 2022 at 13:52):

I don't really see the gain from any of this... just another non-compositional thing to learn.

Eric Wieser (Jan 10 2022 at 14:01):

have := foo bar,
rw baz at this,
exact this

feels awfully verbose, and often leads to ugly golfs with the frustrating triangle that would be more readable as:

rwa baz at foo bar

I guess the other way of looking at it is that we shouldn't have rwa either, as rw foo, assumption works fine and is compositional.

Arthur Paulino (Jan 10 2022 at 14:03):

Novice input: I think it's easier to learn when things have more structure. Making rwa more similar to simpa would probably turn it into less things to learn

Reid Barton (Jan 10 2022 at 14:04):

it's not real structure though

Anne Baanen (Jan 10 2022 at 14:05):

How about an almost term tac tactic that works like exact term except it applies tac to term first?

Alex J. Best (Jan 10 2022 at 14:06):

Eric Wieser said:

have := foo bar,
rw baz at this,
exact this

feels awfully verbose, and often leads to ugly golfs with the frustrating triangle that would be more readable as:

rwa baz at foo bar

I guess the other way of looking at it is that we shouldn't have rwa either, as rw foo, assumption works fine and is compositional.

Doesn't

have := foo bar,
rwa baz at this,

work for your example though? so its not that long?

Anne Baanen (Jan 10 2022 at 14:06):

So simpa [eqs] using term = almost term { simp [eqs] } and rwa [eqs] using term = almost term { rw [eqs] }

Eric Wieser (Jan 10 2022 at 14:27):

Are you proposing an almost tactic, @Anne Baanen?

Anne Baanen (Jan 10 2022 at 14:30):

I would prefer having a tactic like that over duplicate logic in rwa/simpa.

Eric Rodriguez (Jan 10 2022 at 14:40):

simpa simplifies both the using term and the goal, so I'm not too sure that almost would work

Eric Rodriguez (Jan 10 2022 at 14:41):

I feel like it's mostly useful for one-liners to have this sort of thing, as rwa ... using flows a lot better than let x := ... in by rwa ... at this

Anne Baanen (Jan 12 2022 at 16:08):

Another example of a simpa-like tactic: tactic#exact_mod_cast


Last updated: Dec 20 2023 at 11:08 UTC