Zulip Chat Archive

Stream: new members

Topic: Show inferred value for `_` with vscode-lean4


Aaron Hill (Sep 16 2024 at 15:19):

If I have an expression like exact h1 _, hovering over the _ in vscode-lean4 will show the inferred type (e.g. N). Is there a way to also show the actual term that was inferred (something like p + 1)? So far, I've been able to figure it out by looking at how the goal changes in the infoview as I move my cursor around, but it would be nice to have a more explicit way of seeing that

Luigi Massacci (Sep 16 2024 at 15:33):

You can always use show_term, but that is rather brutish

Luigi Massacci (Sep 16 2024 at 15:34):

Hopefully there is a better way I don't know

Aaron Hill (Sep 16 2024 at 16:10):

Thanks - that worked. Separately, it looks like hovering has the expected behavior (showing term: type) in most cases, but not for the particular placeholder I was looking at. I'll see if I can come up with a minimized example

Filippo A. E. Nuccio (Sep 16 2024 at 16:11):

image.png

Filippo A. E. Nuccio (Sep 16 2024 at 16:11):

I see the name of the term, which version of the lean4 extension are you using?

Filippo A. E. Nuccio (Sep 16 2024 at 16:12):

Same behaviour online

Aaron Hill (Sep 16 2024 at 16:44):

I've managed to minimize the issue to this snippet:

theorem bad_lsp (h:  m : Nat, Nat.zero = m) : Nat.zero = (Nat.zero + Nat.zero) := by show_term exact h _

The show_term output is Try this: exact h (Nat.zero + Nat.zero). However, hovering over the _ just shows Nat.
If you replace (Nat.zero + Nat.zero) with (Nat.zero) in the theorem header, then hovering over the _ shows Nat.zero: Nat as expected

Aaron Hill (Sep 16 2024 at 16:45):

I'll see if I can simplify this any further, then open a bug

Aaron Hill (Sep 16 2024 at 17:17):

https://github.com/leanprover/lean4/issues/5367

Filippo A. E. Nuccio (Sep 17 2024 at 08:32):

Wow, and crazily enough if you invert the order as in

theorem bad_lsp (h:  m : Nat, m = Nat.zero) : Nat.zero = (Nat.zero + Nat.zero) := by show_term exact h _

you see the term.


Last updated: May 02 2025 at 03:31 UTC