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

split runs out of heartbeats with nested matches and as-patterns #6065

Closed
3 tasks done
TwoFX opened this issue Nov 13, 2024 · 1 comment · Fixed by #6146
Closed
3 tasks done

split runs out of heartbeats with nested matches and as-patterns #6065

TwoFX opened this issue Nov 13, 2024 · 1 comment · Fixed by #6146
Labels
bug Something isn't working P-medium We may work on this issue if we find the time

Comments

@TwoFX
Copy link
Member

TwoFX commented Nov 13, 2024

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

def foo (r : Nat) : Nat :=
  match r with
  | Nat.zero => 0
  | l@(Nat.succ _) =>
    match l with
    | 0 => 0
    | Nat.succ ll =>
      match ll with
      | Nat.succ _ => 0
      | _ => 0

/--
error: tactic 'simp' failed, nested error:
(deterministic) timeout at `whnf`, maximum number of heartbeats (200000) has been reached
Use `set_option maxHeartbeats <num>` to set the limit.
Additional diagnostic information may be available using the `set_option diagnostics true` command.
-/
#guard_msgs in
example {r : Nat} : foo r = 0 := by
  simp only [foo.eq_def]

Context

Found while working on the ordered tree.

Expected behavior: No error

Actual behavior: See above

Versions

4.15.0-nightly-2024-11-13 on live.lean-lang.org

Impact

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

@TwoFX TwoFX added the bug Something isn't working label Nov 13, 2024
@nomeata
Copy link
Collaborator

nomeata commented Nov 13, 2024

The issue isn’t the unfolding, it’s what happens afterwards; and it seems to be related to creating the splitter =:

def foo (r : Nat) : Nat :=
  match r with
  | Nat.zero => 0
  | l@(Nat.succ _) =>
    match l with
    | 0 => 0
    | Nat.succ ll =>
      match ll with
      | Nat.succ _ => 0
      | _ => 0

set_option maxHeartbeats 20000

/--
error: (deterministic) timeout at `whnf`, maximum number of heartbeats (20000) has been reached
Use `set_option maxHeartbeats <num>` to set the limit.
Additional diagnostic information may be available using the `set_option diagnostics true` command.
-/
#guard_msgs in
example {r : Nat} : foo r = 0 := by
  unfold foo
  -- trace_state
  split
  · rfl
  · split
    · rfl
    · split

@nomeata nomeata changed the title simp runs out of heartbeats when unfolding a definition simp runs out of heartbeats with nested matches and as-patterns Nov 13, 2024
@nomeata nomeata changed the title simp runs out of heartbeats with nested matches and as-patterns split runs out of heartbeats with nested matches and as-patterns Nov 13, 2024
@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label Nov 15, 2024
leodemoura added a commit that referenced this issue Nov 21, 2024
…orem

This PR fixes a non-termination bug that occurred when generating the
match-expression splitter theorem. The bug was triggered when the
proof automation for the splitter theorem repeatedly applied `injection` to
the same local declaration, as it could not be removed due to forward
dependencies. See issue #6065 for an example that reproduces this
issue.

closes #6065
github-merge-queue bot pushed a commit that referenced this issue Nov 21, 2024
…orem (#6146)

This PR fixes a non-termination bug that occurred when generating the
match-expression splitter theorem. The bug was triggered when the proof
automation for the splitter theorem repeatedly applied `injection` to
the same local declaration, as it could not be removed due to forward
dependencies. See issue #6065 for an example that reproduces this issue.

closes #6065
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium We may work on this issue if we find the time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants