lean-py
Effortless interop between Lean 4 and Python, in both directions.
Lean -> Python. Annotate any Lean definition with
@[python "name"]and call it from Python with automatic type marshalling.derive_pythonexposes inductives and structures as Python constructors.Python -> Lean.
LeanPy.Pythongives Lean code aPytype withimport_,eval,exec,getAttr,call, etc. CPython is loaded lazily viadlopen.Kernel facade.
LeanPy.Kernelwraps the Pantograph library so a Python process can drive Lean’s type-checker, elaborator, and tactic engine without spawning a subprocess.
Getting Started
Examples
API Reference