Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Lean Client

A Python client for the Lean Server API.

This package provides a simple, asynchronous LeanClient to interact with the lean-server.

📦 Installation

As a Standalone Package

To install this package from PyPI (once published):

pip install lean-client

For Development

This package is part of a monorepo. For development, follow the setup instructions in the root README. The recommended installation command within the dev container is:

# This installs the client in editable mode
uv pip install -e .

🚀 Usage

The client is asynchronous and designed to be used with asyncio.

Basic Usage

Here is a basic usage example:

import asyncio
from lean_client import LeanClient

async def main():
    # Assumes the server is running on http://localhost:8000
    # The client can be used as an async context manager.
    async with LeanClient("http://localhost:8000") as client:
        proof_to_check = "def my_theorem : 1 + 1 = 2 := rfl"

        # Optional configuration can be passed as a dictionary.
        config = {"timeout": 60}

        print(f"Checking proof: '{proof_to_check}'")
        result = await client.check_proof(proof_to_check, config=config)

        print("\nServer response:")
        print(result)

if __name__ == "__main__":
    # To run the example, save it as a file (e.g., `test_client.py`)
    # and run `python test_client.py` in a terminal where the server is running.
    asyncio.run(main())

File Support

The client supports multiple ways to provide proof content:

  1. String content directly:
proof_content = "theorem test : 1 + 1 = 2 := by rfl"
result = await client.check_proof(proof_content)
  1. File path as string:
result = await client.check_proof("path/to/proof.lean")
  1. Path object:
from pathlib import Path
proof_file = Path("path/to/proof.lean")
result = await client.check_proof(proof_file)

Complete Example with File

import asyncio
from pathlib import Path
from lean_client import LeanClient

async def check_proof_from_file():
    async with LeanClient("http://localhost:8000") as client:
        # Create a test Lean file
        proof_file = Path("test_proof.lean")
        proof_content = """
theorem test_theorem : 1 + 1 = 2 := by
  rw [add_comm]
  rw [add_zero]
  rfl
"""

        # Write content to file
        with open(proof_file, 'w', encoding='utf-8') as f:
            f.write(proof_content)

        try:
            # Check proof from file
            result = await client.check_proof(proof_file, config={"timeout": 30})
            print(f"Proof check result: {result}")
        finally:
            # Clean up
            if proof_file.exists():
                proof_file.unlink()

if __name__ == "__main__":
    asyncio.run(check_proof_from_file())

📚 API Reference

LeanClient

The main client class for interacting with the Lean Server.

__init__(base_url: str)

Initialize the client with the server's base URL.

async check_proof(proof: Union[str, Path, os.PathLike], config: dict[str, Any] | None = None) -> dict[str, Any]

Send a proof to the server for checking.

Parameters:

  • proof: The proof content. Can be:
    • A string containing the proof
    • A Path object pointing to a file containing the proof
    • A string path to a file containing the proof
  • config: Optional configuration dictionary for the proof check

Returns:

  • A dictionary containing the server's response

async close()

Close the client session.

async __aenter__() and async __aexit__()

Async context manager support for automatic session management.

Metadata

Release files for lmms-lean-client 0.0.1.dev4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lmms-lean-client 0.0.1.dev4
File Size Uploaded Provenance
lmms_lean_client-0.0.1.dev4.tar.gz 8.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lmms-lean-client 0.0.1.dev4
File Interpreter ABI Platform
lmms_lean_client-0.0.1.dev4-py3-none-any.whl Python 3 none any Details

Total release size: 16.8 kB

Release files / lmms_lean_client-0.0.1.dev4.tar.gz

Download URL lmms_lean_client-0.0.1.dev4.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
59ba435309306661014b289c360376757f4a9f8e11a032b24c3e2f895876176e
BLAKE2b-256 checksum
How to use checksums
40c5983c1050f2f375a57bf0460b63f2ff7be589736b3671ff47329aad718cc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.5

Release files / lmms_lean_client-0.0.1.dev4-py3-none-any.whl

Download URL lmms_lean_client-0.0.1.dev4-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57df4920a73c0efecdbfe436d6fd765afff17d0912315b7ab2e5c48999b828dd
BLAKE2b-256 checksum
How to use checksums
fe31ffd6477a17edd180e099542d9750ba50e15fffd2e40831776cf0c753c316
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.5

Security for lmms-lean-client 0.0.1.dev4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page