Zulip Chat Archive

Stream: new members

Topic: contraposition


view this post on Zulip Henning Dieterichs (Nov 13 2020 at 18:17):

Sorry for this stupid question. My goal is to show A -> B. I would like to rewrite this goal to \neg B -> \neg A. How do I do that? I know I could prove (A -> B) -> (\neg B -> \neg A) and use rewrite, but I was hoping for something built in

view this post on Zulip Kevin Buzzard (Nov 13 2020 at 18:18):

This result will be in the library -- is it called something like neg_imp_neg or something?

view this post on Zulip Henning Dieterichs (Nov 13 2020 at 18:18):

What is the best way to search the library?

view this post on Zulip Kevin Buzzard (Nov 13 2020 at 18:19):

import tactic

example (A B : Prop) : (¬ B  ¬ A)  (A  B) := by library_search

view this post on Zulip Kevin Buzzard (Nov 13 2020 at 18:19):

not_imp_not

view this post on Zulip Kevin Buzzard (Nov 13 2020 at 18:20):

That's one way. Another way is to guess what the result is called using #naming and start to type your guess and see what VS Code predicts. import tactic imports a bunch of stuff, making library_search more likely to succeed.

view this post on Zulip Kevin Buzzard (Nov 13 2020 at 18:21):

As you can see, you tripped me up by calling it neg, but #naming tells us it's called not

view this post on Zulip Henning Dieterichs (Nov 13 2020 at 18:23):

Thanks, I didn't know about these naming guidelines or library_search ;) not_imp_not works as expected

view this post on Zulip Kevin Buzzard (Nov 13 2020 at 18:23):

Yeah, there are a lot of secrets :-) Useful tactics get written much faster than useful documentation of the tactics. https://leanprover-community.github.io/mathlib_docs/tactics.html

view this post on Zulip Henning Dieterichs (Nov 13 2020 at 18:24):

Can I somehow list all tactics that are applicable at the current position?

view this post on Zulip Henning Dieterichs (Nov 13 2020 at 18:25):

Or all lemmas l so that rw l succeeds?

view this post on Zulip Bryan Gin-ge Chen (Nov 13 2020 at 18:25):

tactic#hint for the former, rw_hint is supposed to do the latter, but the PR #2030 was closed without being merged.

view this post on Zulip Bryan Gin-ge Chen (Nov 13 2020 at 18:26):

hint won't give anything like a complete list

view this post on Zulip Bryan Gin-ge Chen (Nov 13 2020 at 18:26):

but maybe it's still useful

view this post on Zulip Henning Dieterichs (Nov 13 2020 at 18:27):

wow, hint is useful, thanks

view this post on Zulip Kevin Buzzard (Nov 13 2020 at 18:27):

PS "stupid" questions are welcome in #new members , you're doing exactly the right thing

view this post on Zulip Patrick Massot (Nov 13 2020 at 19:34):

@Henning Dieterichs see also the contrapose tactic.

view this post on Zulip Henning Dieterichs (Nov 13 2020 at 19:36):

thanks! I tried contrapose/contraposition before, but I couldn't find it in the standard documentation. I didn't import tactic though, but now, after I did, it works


Last updated: May 08 2021 at 19:11 UTC