Skip to content

LexLeanRuntime.Laws loops forever when Lean 4.32.1 emits C for it (breaks Prism app builds, PP5007) #454

Open

Description

@maurathat

LexLeanRuntime.Laws` loops forever when Lean 4.32.1 emits C for it (breaks Prism app builds, PP5007)

Compiling the runtime module LexLeanRuntime.Laws (language 1.2) with C output never finishes. Lean 4.32.1's compiler hits two assertions and then panics in a loop:

PANIC at Lean.Compiler.LCNF.getImpureDeclIndices Lean.Compiler.LCNF.PhaseExt:238:4: assertion violation: i != 0
PANIC at Lean.Compiler.LCNF.getImpureDeclIndices Lean.Compiler.LCNF.PhaseExt:240:2: assertion violation: map.size == targets.size
PANIC at Std.DHashMap.Internal.AssocList.get! Std.Data.DHashMap.Internal.AssocList.Basic:163:11: key is not present in hash table
(the last line repeats until the process is killed: 1,219 times in 30 seconds, 4 MB of output)

The same module compiles in about 3 seconds without -c.

Why it matters

LexLean imports LexLeanRuntime.Laws into any module with a linear_arithmetic or law proof. PrismPM's application-lean stage runs lake build, which emits C for every module, so a Prism text application whose modules reach such a proof never builds. It fails with PP5007: application-lean timed out after 600 seconds and gives no hint of the cause.

Reproduction (Lean 4.32.1, x86_64-unknown-linux-gnu, commit f054605a)

  1. lexlean build the runtime library at language/runtime-1.2/library. I used LexLean at the commit before the 0.4.0 bump, which matches the 0.3.0 SDK.
  2. Put the generated LexLeanRuntime/{Portable,Collections,Reasoning,Laws}.lean in a lake project with roots = ["LexLeanRuntime.Portable","LexLeanRuntime.Collections","LexLeanRuntime.Reasoning","LexLeanRuntime.Laws"].
  3. lake build. It hangs on LexLeanRuntime.Laws.
  4. Directly: lake env lean LexLeanRuntime/Laws.lean -o out.olean -c out.c loops, while lake env lean LexLeanRuntime/Laws.lean -o out.olean exits 0 at once.

The runtime from LexLean 0.4.0 (main) behaves the same way.

Workaround we use

We keep every theorem in separate …Laws modules and build the Prism app from a second LexLean project whose entry points reach only the definition modules. With that change the app's Lean build takes 4 seconds. (Kappa Exchange: kx-model/lexlean-app.toml.)

Possible fixes

  • Mark the Laws declarations that the compiler need not touch as noncomputable, or move its JSON/Name helpers (fail, field, nameOf, …) out of the proof-only module, so the compiler never sees them.
  • Or have the runtime import Laws only at proof time, so app builds never include it.
  • The underlying LCNF assertion is likely a Lean bug worth reporting to leanprover/lean4 once LexLean has a minimal reproduction.

Activity

  1. afflom commented on Nov 10, 2026

    @afflom
    Member

    Read-only triage confirms that linear_arithmetic/law modules can import LexLeanRuntime.Laws, and our existing verifier invokes Lean for .olean output without -c. Those checks therefore do not establish that the downstream C-emission path succeeds.

    Could you attach the exact four generated Lean inputs (Portable, Collections, Reasoning and Laws), the Lake configuration, and the exact LexLean commit used? The reported Lean identity is already specific. Reusing those inputs would let us isolate the -o versus -o -c difference without regenerating the runtime or repeating the full application build.

    The suggested decoder helpers are emitted by the core backend; they are not authored in Laws.lex.tex. Laws also contains executable sum definitions, so blanket noncomputable marking or removing the import needs a semantic review before adoption. No reproduction or repair is claimed yet, and this is separate from the existing #433 toolchain upgrade and #437 formatting work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions