Zulip Chat Archive

Stream: general

Topic: contrapose


Johan Commelin (Aug 05 2019 at 18:56):

@Patrick Massot I have a feature request.
I would like to do contrapose foo with bar. Because now the hypothesis name just gets reused, but this can create severe semantic dissonance.

Johan Commelin (Aug 05 2019 at 18:56):

H_nonzero : y  0
 l q  0

Johan Commelin (Aug 05 2019 at 18:56):

contrapose! H_nonzero

Johan Commelin (Aug 05 2019 at 18:57):

H_nonzero : l q = 0
 y = 0

Kevin Buzzard (Aug 05 2019 at 19:32):

I just do intro bar, apply foo which I think is shorter! I didn't know about contrapose

Kevin Buzzard (Aug 05 2019 at 19:32):

But it sounds good for beginners.

Rob Lewis (Aug 05 2019 at 19:37):

I just used contrapose for the first time today in the sensitivity proof. It's suprisingly useful, especially the ! variant that fixes double negations.

Rob Lewis (Aug 05 2019 at 19:37):

https://github.com/leanprover-community/mathlib/pull/1302

Johan Commelin (Aug 05 2019 at 19:40):

Right, with ! it is really powerful. It fixes double negations, but also changes \not \exists into \forall and vice versa.

Johan Commelin (Aug 05 2019 at 19:40):

And it does this recursively

Johan Commelin (Aug 05 2019 at 19:40):

(This feature is also available standalone, as push_neg)

Johan Commelin (Aug 05 2019 at 19:41):

Once again: kudos to @Patrick Massot

Johan Commelin (Aug 05 2019 at 19:41):

@Rob Lewis does #1302 also clear the old hypothesis?

Johan Commelin (Aug 05 2019 at 19:42):

Because that would make sense, I think. Otherwise you end up with a hypothesis that is the negation of the goal. Pretty useless, as long as Lean is consistent :wink:

Rob Lewis (Aug 05 2019 at 19:43):

Yes, it reverts the old hypothesis, contraposes the goal, then introduces the new hypothesis with the new name.

Johan Commelin (Aug 05 2019 at 19:44):

Awesome!

Johan Commelin (Jan 25 2020 at 09:01):

Sometimes contrapose fails because I'm not in classical mode. What do people think of enhancing contrapose so that it invokes classical automatically in such cases?

Patrick Massot (Jan 25 2020 at 09:12):

Indeed this tactic doesn't make much sense in anon-classical context. It could start with classical.

Johan Commelin (Jan 25 2020 at 09:15):

Well, sometimes it works... If you're doing fake proof by contradiction.


Last updated: Dec 20 2023 at 11:08 UTC