Repository navigation
feat(Util): support noWS in notation3 - #45029
YaelDillies wants to merge 1 commit into
Conversation
... and use it to define the conditional probability notation `μ[|s]`. Generated by Claude Opus, reviewed line-by-line by myself. Assisted-by: Claude Opus 5.5
PR summary 0ebe647d41Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
Thanks. This looks good to me, but I'd like a second pair of eyes as I'm not deeply familiar with this. |
|
🚀 Pull request has been placed on the maintainer queue by grunweg. |
| meta def condUnexpander : Lean.PrettyPrinter.Unexpander | ||
| | `($_ $μ $s) => `($μ[|$s]) | ||
| | _ => throw () | ||
| scoped notation3:max μ noWs "[" t " | " s "]" => ProbabilityTheory.cond μ s t |
There was a problem hiding this comment.
This syntax is a little wird to me, in that μ and noWs look syntactically similar, but one is a special token and one is a placeholder.
There was a problem hiding this comment.
But this is taken from notation and macro, etc... Surely consistency is best here?
There was a problem hiding this comment.
In what way is it taken from notation? notation:max μ noWs "[" t " | " s "]" => (μ, t, s) means "create a variable called noWs".
There was a problem hiding this comment.
Sorry I guess just macro
There was a problem hiding this comment.
Macro doesn't support someVar noWs either, you have to write someVar:term noWs
There was a problem hiding this comment.
I agree that the syntax of noWs looks a bit strange here.
There was a problem hiding this comment.
Maybe it could be mu:noWs? I think this makes sense since you having no whitespace is a sort of precedence.
| @[inherit_doc ProbabilityTheory.cond] | ||
| scoped macro:max μ:term noWs "[|" s:term "]" : term => | ||
| `(ProbabilityTheory.cond $μ $s) | ||
| scoped notation3:max μ noWs "[|" s "]" => ProbabilityTheory.cond μ s |
There was a problem hiding this comment.
Shouldn't this be notation instead of notation3? The old code uses an app_unexpander and not a delaborator.
There was a problem hiding this comment.
The point of this PR is to write it using notation3. Is an app_unexpander better than a delaborator? If so, we could try changing the logic of notation3 to produce an app_unexpander whenever possible.
There was a problem hiding this comment.
@YaelDillies, the whole point of notation3 is that it produces a delaborator (which from #45028 it seems you know). There are situations where a delaborator works and an app_unexpander doesn't, which is why we need notation3 is essential. But for situations where an app_unexpander works, it is preferred because it is simpler as it is purely syntax based.
There was a problem hiding this comment.
Okay, so your PoV is that notation3 should be used over notation iff a delaborator is required over an app_unexpander. What about Eric's comment above that notation doesn't support noWs?
There was a problem hiding this comment.
Well, I think that notation and notation3/notation +delab should support the same things for consistency. So I guess you could talk to core and see if they want to add this feature to notation.
There was a problem hiding this comment.
I don't think that approach makes sense given that notation3 is already different from core because of differing priorities. We should just do our own thing for now, and eventually hopefully core will adapt.
There was a problem hiding this comment.
I worry that the lack of an obvious syntax choice noWs is going to make core developers choose a different syntax, so we end up with two incompatible versions. I don't think we need to wait for the implementation in core to be finished to merge this PR. We only need for core to say "we want to implement this exact syntax too" or "we don't want this at all".
There was a problem hiding this comment.
Vierkantor
left a comment
There was a problem hiding this comment.
The implementation looks fine to me. But I think we should communicate with core before continuing with this.
... and use it to define the conditional probability notation
μ[|s].Generated by Claude Opus, reviewed line-by-line by myself.
Zulip discussion: #mathlib reviewers > status of `notation3` @ 💬
Assisted-by: Claude Opus 5.5