Zulip Chat Archive

Stream: lean4

Topic: Interpreter?


Locria Cyber (Oct 21 2022 at 00:28):

Does Lean 4 have an interpreter?

Henrik Böving (Oct 21 2022 at 06:35):

Since you can #eval executable lean code in your editor yes it does have an interpreter. Specifically it has an interpreter for its lowest level IR.

Sebastian Ullrich (Oct 21 2022 at 08:02):

http://leanprover.github.io/talks/WITS2022.pdf#page=6 (essentially true for the new compiler as well)

Super Veridical (Oct 23 2022 at 11:45):

Are there by any chance plans to employ LLVM jit in the future instead of the interpreter? Is the LCNF work a preparation for this or it's general intermediate representation used for optimization purposes and there are no plans for native backends other C?

Henrik Böving (Oct 23 2022 at 12:00):

LCNF is meant as a general IR for optimization purposes. One of the last bits of the compiler implemented in C++ right now is the optimizer and that is what the LCNF work is supposed to replace (and enhance). We are planning on writing a translator from LCNF to the current IR for garbage collection as a next step to get rid of the C++ part. At some point after that we will also replace the C backend with a LLVM one and at that point we could very much think about using the LLVM JIT for such stuff I assume? Though we haven't talked about that yet.

@Siddharth Bhat do you think that's feasible?

Sebastian Ullrich (Oct 23 2022 at 12:12):

I don't see sufficient motivation for adding one more compilation mode between interpretation and AOT compilation

Mario Carneiro (Oct 23 2022 at 12:14):

it would be great if JIT could replace the interpreter though

Mario Carneiro (Oct 23 2022 at 12:15):

since that would mean you don't have to support a whole separate execution environment, the same stuff that goes to AOT can go to JIT

Sebastian Ullrich (Oct 23 2022 at 12:17):

Issues around un- and reloading code for interactive use looked tough though, so I'm not sure if the result will be any easier. And compilation overhead is a big unknown.

Siddharth Bhat (Oct 23 2022 at 14:28):

@Henrik Böving conceptually, it's feasible to JIT compile the LLVM we generate. However, note that LLVM's JIT is quite slow (it spends a lot of time generating good assembly, as it was originally written for ahead-of-time compilation use-cases). Further, as @Sebastian Ullrich points out, I'm unsure how we'll manage the "state" of the JIT.


Last updated: Dec 20 2023 at 11:08 UTC