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

can't see goal state after case tactic #2881

Closed
1 task done
fpvandoorn opened this issue Nov 15, 2023 · 2 comments · Fixed by #5677
Closed
1 task done

can't see goal state after case tactic #2881

fpvandoorn opened this issue Nov 15, 2023 · 2 comments · Fixed by #5677
Labels
bug Something isn't working new-user-papercuts Issue likely to confuse or otherwise negatively affect new users, even if only a little P-high We will work on this issue

Comments

@fpvandoorn
Copy link
Contributor

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Check that your issue is not already filed.
    • Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to mathlib4 or std4.

Description

In the following example, if you put your cursor on the empty line, indented two spaces (i.e. where the next tactic should be), the goal state shows no goals (i.e. the goal state of finished case zero).
It should show the goal state of the remaining goal(s).

example (n : Nat) : n = n := by
  induction n
  case zero => rfl
  
--^

(note: the same occurs when there is a multi-line tactic block after case zero).

Context

Zulip thread

Versions

Lean 4.2.0

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@fpvandoorn fpvandoorn added the bug Something isn't working label Nov 15, 2023
@fpvandoorn fpvandoorn changed the title can't see goal state after case can't see goal state after case tactic Mar 7, 2024
@nomeata
Copy link
Collaborator

nomeata commented Mar 7, 2024

I also stumbled over this, version 4.6.0-rc1; here is my duplicate issue description (with additional info about de-indenting and other tactics)


Consider

example (n : Nat) : n = n := by
  induction n
  case zero => rfl
  ‸

The natural thing to do next is to move the cursor to the next line, aligned with the case, as shown. But then the proof state is

Tactic state
No goals

If I de-indent once more, to

example (n : Nat) : n = n := by
  induction n
  case zero => rfl
 ‸

I see what I want to see: The list of still open goals

Tactic state
1 goal
n✝: Nat
n_ih✝: n✝ = n✝
⊢ Nat.succ n✝ = Nat.succ n✝

But de-indenting further left seems wrong here.

It does not happen with · nor next; there we get the desired behavior.

Maybe the parser for case can be adjusted accordingly.

Odd, the parsers for next and case look very similar:

syntax (name := case) "case " sepBy1(caseArg, " | ") " => " tacticSeq : tactic

macro "next " args:binderIdent* " => " tac:tacticSeq : tactic => `(tactic| case _ $args* => $tac)

So not sure why it works for some and not the others.

@nomeata nomeata added parser new-user-papercuts Issue likely to confuse or otherwise negatively affect new users, even if only a little labels Mar 7, 2024
@Seasawher
Copy link
Contributor

suffices ... by notation has same issue. (Lean version: v4.8.0-rc1)

example {a b : Nat} (h : a = b) : b ≤ b + 1 := by
  suffices a ≤ a + 1 by
    /-
    a b : Nat
    h : a = b
    ⊢ a ≤ a + 1
    -/
    sorry

  suffices a ≤ a + 1 from by
    /-
    a b : Nat
    h : a = b
    this : a ≤ a + 1
    ⊢ a ≤ a + 1
    -/
    sorry

  simp [h]

@Kha Kha removed the parser label Sep 12, 2024
@leanprover-bot leanprover-bot added the P-high We will work on this issue label Sep 13, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 17, 2024
This PR resolves the following issues related to goal state display:
1. In a new line after a `case` tactic with a completed proof, the state
of the proof in the `case` would be displayed, not the proof state after
the `case`
1. In the range of `next =>` / `case' ... =>`, the state of the proof in
the corresponding case would not be displayed, whereas this is true for
`case`
1. In the `suffices ... by` tactic, the tactic state of the `by` block
was not displayed after the `by` and before the first tactic

The incorrect goal state after `case` was caused by `evalCase` adding a
`TacticInfo` with the full block proof state for the full range of the
`case` block that the goal state selection has no means of
distinguishing from the `TacticInfo` with the same range that contains
the state after the whole `case` block. Narrowing the range of this
`TacticInfo` to `case ... =>` fixed this issue.

The lack of a case proof state on `next =>` was caused by the `case`
syntax that `next` expands to receiving noncanonical synthetic
`SourceInfo`, which is usually ignored by the language server. Adding a
token antiquotation for `next` fixed this issue.

The lack of a case proof state on `case' ... =>` was caused by
`evalCase'` not adding a `TacticInfo` with the full block state to the
range of `case' ... =>`. Adding this `TacticInfo` fixed this issue.

The tactic state of the block not being displayed after the `by` was
caused by the macro expansion of `suffices` to `have` not transferring
the trailing whitespace of the `by`. Ensuring that this trailing
whitespace information is transferred fixed this issue.

Fixes #2881.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new-user-papercuts Issue likely to confuse or otherwise negatively affect new users, even if only a little P-high We will work on this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants