Add Lean4 Support

Lean4 is a fascinating language because it is both a general purpose programming language and a proof assistant (like Ada, Coq, Idris, etc). It’s gaining a lot of adoption in mathematics through its Mathlib with prominent figures like Terence Tao formalizing his textbook in Lean4 (analysis | Reservoir). Google Deepmind has also been working with Lean4 and Mathlib (GitHub - google-deepmind/formal-conjectures: A collection of formalized statements of conjectures in Lean.).

It’s a functional language that also has dependent types (types as a first class language object, like how functional languages have functions as first class language objects), allowing for expressing specific constraints at compile time that would otherwise result in runtime errors, such as a function that only takes vectors of length 3.

I’m of the opinion that with the advent of LLMs writing code, formal verification of software will become more accessible and more mainstream. With that, Lean4 would be a natural choice since the codebase and the verification can be written in the same language.

Hey @adekau, thanks for the detailed note! I’ve added an internal +1 on your behalf. We’re a small team, so it might be a while before we get to this (we try our best to prioritize language support based on user demand).

By the way, more than 50% of the languages we support were contributed by the community, if that’s something you’d be interested in, we have a guide here on how to add a new language: Introduction - CodeCrafters.

1 Like

@adekau BTW, are you familiar with how Lean4 handles networking (TCP/UDP)? I skimmed through the docs but couldn’t find much.

It looks like Lean4 doesn’t have a standard socket/http lib and everything I’m reading about with doing networking in Lean4 is doing it through FFI to c libraries like libcurl

edit: It looks like the lean batteries package (lean-community’s extended std, short for “batteries included”) might have some things Std.Internal.UV.TCP

1 Like