Zulip Chat Archive
Stream: lean4
Topic: Forall x not in
Patrick Massot (Oct 26 2023 at 15:52):
In Lean 3 we could write
variables (s : set nat) (x : nat)
#check ∀ x ∉ s, true
(without any import!). In Lean 4, even importing all of Mathlib is not enough
import Mathlib
variable (s : Set Nat) (x : Nat)
#check ∀ x ∉ s, True
Is this really missing?
Alex J. Best (Oct 26 2023 at 16:06):
yes looks that way, but its easy to add
import Mathlib
variable (s : Set Nat) (x : Nat)
binder_predicate x " ∉ " y:term => `($x ∉ $y)
#check ∀ x ∉ s, True
Patrick Massot (Oct 26 2023 at 16:08):
Thanks Alex, but I think this isn't enough. It will be missing in delaborators.
Alex J. Best (Oct 26 2023 at 16:11):
Looks like that is more hardcoded yeah https://github.com/leanprover-community/mathlib4/blob/8cd944d0aa56ccfd19573ab0199afe25b4431fee/Mathlib/Util/PiNotation.lean#L50
Alex J. Best (Oct 26 2023 at 16:12):
Oh but you wrote that 2 weeks ago?
Patrick Massot (Oct 26 2023 at 16:12):
I know...
Yaël Dillies (Oct 26 2023 at 16:17):
Surely that's covered by @Kyle Miller's binder elaboration suite?
Patrick Massot (Oct 26 2023 at 16:26):
std4#323 @Mario Carneiro
Patrick Massot (Oct 26 2023 at 16:28):
By the way Mario, are you interested in having this file in Std? I could add it to the above PR, updating it for new binders.
Patrick Massot (Oct 26 2023 at 16:28):
Remember you said two weeks ago that this file was good enough for Mathlib until you'll redo it better.
Mario Carneiro (Oct 26 2023 at 16:29):
nope, for one thing it will require a lot more review than the PR you just sent, and for another I will probably push to do it the right way if you do so it will probably take a while
Mario Carneiro (Oct 26 2023 at 16:30):
this is besides the part where I'm not sure we want pi notation, given it was removed from core
Eric Wieser (Oct 26 2023 at 16:32):
Presumably we could split that file in two, and Std could gain the bit that uses the extended binders on forall?
Eric Wieser (Oct 26 2023 at 16:32):
(or at least, exists_delab
)
Mario Carneiro (Oct 26 2023 at 16:33):
yes I think a piece of that file, suitably rewritten, is appropriate for std
Patrick Massot (Oct 26 2023 at 16:56):
Oh no,
variable (x : Nat) (s : Set Nat)
#check x ∉ s
already fails to use the notation.
Patrick Massot (Oct 26 2023 at 16:58):
Is there an easy way to find which delaborator is used? Say I notice that #check 0 ≠ 1
and I want to see which delaborator was used so that I can copy-paste it.
Alex J. Best (Oct 26 2023 at 17:33):
Ne is its own def though, so probably just using the default app unexpander for applications (https://github.com/leanprover/lean4/blob/6c5f79c0df01e9cd74ac4ee411ec392a5ac1b5d3/src/Lean/Elab/Notation.lean#L81), so I'm not sure this would apply in the same way for not in out of the box
Patrick Massot (Oct 26 2023 at 17:38):
I managed to write in only half an hour:
open Lean Lean.PrettyPrinter.Delaborator
@[delab app.Not] def delab_not_in := whenPPOption Lean.getPPNotation do
let #[f] := (← SubExpr.getExpr).getAppArgs | failure
unless f.getAppFn matches .const `Membership.mem _ do failure
let stx₁ ← SubExpr.withAppArg <| SubExpr.withNaryArg 3 delab
let stx₂ ← SubExpr.withAppArg <| SubExpr.withNaryArg 4 delab
return ← `($stx₁ ∉ $stx₂)
I think I deserve some lunch.
Patrick Massot (Oct 26 2023 at 18:18):
I "quickly" created #7964 before lunch.
Last updated: Dec 20 2023 at 11:08 UTC