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_python exposes inductives and structures as Python constructors.

  • Python -> Lean. LeanPy.Python gives Lean code a Py type with import_, eval, exec, getAttr, call, etc. CPython is loaded lazily via dlopen.

  • Kernel facade. LeanPy.Kernel wraps the Pantograph library so a Python process can drive Lean’s type-checker, elaborator, and tactic engine without spawning a subprocess.

Indices and Tables