Zulip Chat Archive

Stream: mathlib4

Topic: push_neg of \and


Nick Andersen (Apr 17 2023 at 21:55):

[I'm new to Lean 4, and Zulip]
When I use push_neg on a statement like ¬(PQ)\lnot (P \land Q), I get P¬QP \rightarrow \lnot Q, but I would like to get ¬P¬Q\lnot P \lor \lnot Q. (I realize that these are equivalent, but they behave differently in Lean, e.g. I can use "left" or "right" on the latter, which I can't do with the former.) Is there some way to get the latter behavior?

Adam Topaz (Apr 17 2023 at 21:59):

you could rewrite with docs4#not_and_or

Nick Andersen (Apr 17 2023 at 22:03):

Sure, in this simple example that works great, but in a more complicated expression it would be really nice to just use push_neg, or some variant, to simplify the whole expression. I'm thinking about this from a possible student's perspective mostly.

Adam Topaz (Apr 17 2023 at 22:06):

In practice the form P¬QP \to \lnot Q is more useful because you can use intro hP and that leaves the goal ¬Q\lnot Q, so that's similar to the "right" branch, except you also obtain hP in context.

Adam Topaz (Apr 17 2023 at 22:08):

Of course, if you wanted the left branch, then that's an issue. But you can use exfalso and revert hP (or some other tricks) to obtain this.

Kyle Miller (Apr 17 2023 at 22:24):

@Nick Andersen It might seem like push_neg is doing something crazy here, but one of the main uses of it is to negate forall and exists. The proposition (n>0),p(n)\exists(n > 0), p(n) is encoded as n,n>0p(n)\exists n, n>0 \wedge p(n) and (n>0),p(n)\forall(n>0), p(n) as n,n>0p(n)\forall n, n>0 \to p(n), so if you want ¬(n>0),p(n)\neg\exists(n>0), p(n) to be (n>0),¬p(n)\forall(n>0),\neg p(n) you sort of want ¬(n>0p(n))\neg(n>0\wedge p(n)) to be n>0¬p(n)n>0\to\neg p(n).

Kyle Miller (Apr 17 2023 at 22:26):

Though I think I remember @Heather Macbeth doing something to push_neg for your use case (for teaching)

Alex J. Best (Apr 17 2023 at 22:26):

Indeed: if you hover over the tactic push neg and read the docstring at the end it explains that setting set_option push_neg.use_distrib true does what you want

Heather Macbeth (Apr 18 2023 at 00:01):

The Lean 4 version of this option was done by @Frédéric Dupuis and @Jireh Loreaux as a favour to me; I later backported it to Lean 3.

Nick Andersen (Apr 18 2023 at 02:54):

Excellent -- that's exactly what I was looking for. Thanks!


Last updated: Dec 20 2023 at 11:08 UTC