Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match-syntax leftovers #1345

Closed
leodemoura opened this issue Jul 21, 2022 · 6 comments
Closed

match-syntax leftovers #1345

leodemoura opened this issue Jul 21, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@leodemoura
Copy link
Member

The auxiliary variables created by match-syntax expander are visible in the infoview.
It does not bother the developers too much because most of us use Emacs, but during the ICERM after-party hackton, it was an issue for people using VS Code.
Example:
image

@leodemoura leodemoura added the enhancement New feature or request label Jul 21, 2022
@digama0
Copy link
Collaborator

digama0 commented Jul 22, 2022

Suggestion: clear% x y in e term mode syntax for clear as part of the generated code for the quotation. (% because I don't know if clear being a keyword will cause problems.) Alternatively, a let_fun with the match body can be introduced before all the lets are created (not sure if this affects the performance).

@Kha
Copy link
Member

Kha commented Jul 22, 2022

The auxiliary variables are shown here only because of forward dependencies from the let-bound pattern variables. I think the more fundamental question is, should we even show the value of let-bound variables at all in programming contexts? I'm pretty sure no other programming language does that at least. Not sure if hiding them based on the Prop-ness of the goal would be confusing when switching between prop and data contexts within the same definition (however, that is already true for the current hiding logic of inaccessibles). If that seems likely, a compromise could be to only hide let values that contain inaccessibles in non-prop contexts, as these were certainly not written down by the user at least.

@gebner
Copy link
Member

gebner commented Aug 8, 2022

I think the more fundamental question is, should we even show the value of let-bound variables at all in programming contexts?

I think we should absolutely show let-values, because they are just as important as types. For example, let_fun n := 42; (.ofNat 0 : Fin n) doesn't type-check but let n := 42; (.ofNat 0 : Fin n) does. (And this is essentially what the term goal display should answer: what do I need to construct here, what will type check here?)

There is an argument to be made to (maybe) collapse (large) let-values by default (à la leanprover/vscode-lean4#76 (comment)), but there should definitely be an indication that this is a let-binding, and the let-value should be inspectable in the infoview.

I'm pretty sure no other programming language does that at least.

Most other programming languages don't have ζ-reduction (on the type level), so the let-value doesn't make a difference for type-checking. And most don't show the local context at all.

switching between prop and data contexts

Note that Prop is an extremely flaky heuristic: there's lots of stuff in Type that behaves like a proposition. For example, bundled isomorphisms serve a similar purpose as equalities (we even have a rewrite tactic for them in mathlib). It's confusing when they are hidden differently.

@digama0
Copy link
Collaborator

digama0 commented Aug 8, 2022

Another idea might be to somehow discourage the use of let bound variables entirely in programming contexts. I think that it is very rare to actually need a dependent let, but the current situation encourages using let way more than required. The best mechanism I can think of is to rename let to let dep or def or something and make let in do blocks and possibly elsewhere mean have instead.

@Kha
Copy link
Member

Kha commented Aug 9, 2022

It's a bit like in the module system: perhaps reducibility is not the right default after all, in all cases.

@leodemoura
Copy link
Member Author

Another idea might be to somehow discourage the use of let bound variables entirely in programming contexts. I think that it is very rare to actually need a dependent let, but the current situation encourages using let way more than required. The best mechanism I can think of is to rename let to let dep or def or something and make let in do blocks and possibly elsewhere mean have instead.

I think this is a good change.

I agree we rarely need dependent let in programming contexts, the main exception is local instances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants