Zulip Chat Archive

Stream: lean4 dev

Topic: Lean 4 hanging - unsure how to debug


Tobias Grosser (Nov 01 2024 at 00:19):

I am currently debugging some kernel busyloop in lean and am very lost.

Tobias Grosser (Nov 01 2024 at 00:19):

At a high-level, I want to proof these two statements equal:

def lhs :
    Com InstCombine.LLVM [] .pure (InstCombine.Ty.bitvec 32) := sorry

def aaaaa:
    Com InstCombine.LLVM [] .pure (InstCombine.Ty.bitvec 32) :=
  .var (const 32 (-1)) <|
  .var (add 32 0 0 ) <|
  .var (neg 32 0) <|
  .ret 1, by simp [Ctxt.snoc]

Tobias Grosser (Nov 01 2024 at 00:19):

In this repo: https://github.com/opencompl/lean-mlir/tree/lean-deadlock

Tobias Grosser (Nov 01 2024 at 00:20):

I tried the last two days reducing the test case, but was unsuccessful.

Tobias Grosser (Nov 01 2024 at 00:20):

I call a couple of tactics to simplify the aaaaa rhs of my lhs = aaaaa identity.

Tobias Grosser (Nov 01 2024 at 00:20):

The tactics succeed, but lean hangs in the kernel.

Tobias Grosser (Nov 01 2024 at 00:21):

set_option debug.skipKernelTC true stops lean hanging.

Tobias Grosser (Nov 01 2024 at 00:22):

And replacing the -1 (which seems to be translated to a large unsigned value) to 0, 1, or any small positive number also accelerates things.

Tobias Grosser (Nov 01 2024 at 00:22):

At 60000 the lean kernel kernel becomes slow again and starts hanging.

Tobias Grosser (Nov 01 2024 at 00:22):

The entire hanging is very fragile.

Tobias Grosser (Nov 01 2024 at 00:23):

I found a different sequence of tactics (replacing simp with rw) that leads to the exact same output with set_option pp.all true enabled.

Tobias Grosser (Nov 01 2024 at 00:23):

Still, when this state is generated with rw lean's kernel check is fast, but when using simp lean hangs.

Tobias Grosser (Nov 01 2024 at 00:25):

I am a bit out of my depth with respect to how to debug this.

Tobias Grosser (Nov 01 2024 at 00:54):

With `set_options diagnostics true' I get:

[kernel] unfolded declarations (max: 150035, num: 44): 
  [] Nat.rec  150035
  [] Nat.casesOn  90048
  [] Nat.add.match_1  30004
  [] Nat.beq.match_1  30001
  [] InstCombine.Ty  411

Tobias Grosser (Nov 01 2024 at 00:55):

The number of Nat.rec increases as I increase the integer value in my input. So it seems there is too much unfolded here.

Tobias Grosser (Nov 01 2024 at 02:26):

I tried https://github.com/leanprover/lean4/issues/5724 and it seems one of my reduced test cases is solved by it.

Tobias Grosser (Nov 01 2024 at 02:27):

I am currently looking back to debugging why the full test case. I see similar hanging there.


Last updated: May 02 2025 at 03:31 UTC