Zulip Chat Archive
Stream: mathlib4
Topic: RFC: contrapose for `a ↔ b`
Jovan Gerbscheid (Nov 09 2025 at 12:35):
Would it be a reasonable feature for contrapose/contrapose!, when applied to a goal a ↔ b, to turn it into ¬ a ↔ ¬ b? This doesn't interfere with the current behaviour, since contrapose without arguments only works when the goal is of the form a → b, turning it into ¬ b → ¬ a.
Weiyi Wang (Nov 09 2025 at 14:06):
The current magic spell for this is rw [← not_iff_not] but it always takes me some time to remember it / find it
Jovan Gerbscheid (Nov 09 2025 at 14:44):
And usually, you want to push the negation as well, so contrapose! would do this conveniently.
Jireh Loreaux (Nov 09 2025 at 18:47):
I like this.
Jovan Gerbscheid (Nov 10 2025 at 00:22):
A somewhat orthogonal idea I had is that it might be nice for contrapose (without the !) to cancel out a negation that is already present. So it would e.g. replace a → ¬ b with b → ¬ a. This way, it is not "pushing" the negation, but just "cancelling" it. Note that the by_contra and absurd tactics already have this feature.
I can imagine that one might not want to run the full power of push_neg (i.e. not use contrapose!), but I cannot imagine why one wouldn't want to cancel out a double negation. (And doing this with a single lemma would create smaller proof terms, and avoid classical logic sometimes)
Patrick Massot (Nov 11 2025 at 10:54):
About contrapose for equivalences, I think it would be nice to include an option to turn it off, for people who directly use contrapose for teaching.
Michael Rothgang (Nov 11 2025 at 15:51):
Jovan just made #31510 which does this (including a teaching option). I'm reviewing it, and have a specification question: do we prefer contrapose on a ↔ b to yield ¬ a ↔ ¬ b or ¬ b ↔ ¬ a?
Michael Rothgang (Nov 11 2025 at 15:51):
I would have expected the latter (and that matches the behaviour for implications). What do others think? Let's have a poll:
Michael Rothgang (Nov 11 2025 at 15:52):
/poll What should contrapose do to a bi-implication a ↔ b?
¬ a ↔ ¬ b
¬ b ↔ ¬ a
nothing, i.e. this thread is a bad idea
Last updated: Dec 20 2025 at 21:32 UTC