Python client for AxMath theorem proving API - connects to private AxMath service
Project description
AxMath Client
Python client for the AxMath theorem proving API - connects to private AxMath service.
⚠️ This is a client library only. The actual theorem proving happens on private AxMath servers. You need an API key to use this service.
Installation
pip install axmath-client
Quick Start
1. Get API Key
Register at https://axmath.yourdomain.com/auth/register to get your API key.
2. Set Environment Variable
export AXMATH_API_KEY="axm_abc123..."
3. Use the Client
from axmath_client import AxMath
# Initialize client (uses AXMATH_API_KEY from environment)
client = AxMath()
# Prove a theorem
result = client.prove("Sum of two even numbers is even")
if result.verified:
print("✅ Proof verified!")
print(result.lean_code)
else:
print("❌ Proof failed")
print(result.verification_details.errors)
# Search for relevant premises
search_result = client.search("Cauchy-Schwarz inequality", k=5)
for premise in search_result.premises:
print(f"{premise.similarity:.3f} - {premise.full_name}")
# Solve complex problems with multi-agent orchestration
solve_result = client.solve(
"Prove that sqrt(2) is irrational and verify numerically"
)
print(solve_result.synthesis)
Features
- ✅ Theorem Proving - Generate LEAN 4 proofs with DeepSeek-Prover-V2
- ✅ Premise Search - Search 180K mathlib4 premises with FAISS
- ✅ Formal Verification - Verify LEAN code compilation
- ✅ Multi-Agent Solving - Orchestrate complex problem solving
- ✅ Async Support - Full async/await API
- ✅ Type Safe - Pydantic models for all responses
API Reference
AxMath(api_key=None, api_url=None, timeout=120.0)
Initialize client.
Parameters:
api_key(str, optional): API key. If not provided, reads fromAXMATH_API_KEYenv var.api_url(str, optional): API base URL. Defaults to production server.timeout(float): Default timeout for requests in seconds.
Example:
# Option 1: Environment variable
client = AxMath()
# Option 2: Pass API key directly
client = AxMath(api_key="axm_abc123...")
prove(statement, search_premises=True, max_iterations=10, timeout=None)
Prove a theorem in LEAN 4.
Parameters:
statement(str): Theorem to prove (natural language or LEAN syntax)search_premises(bool): Search for relevant mathlib4 premisesmax_iterations(int): Maximum proving iterationstimeout(float, optional): Override default timeout
Returns: ProveResult
verified(bool): Whether proof was verifiedlean_code(str): Generated LEAN codeiterations(int): Number of iterations usedtotal_time(float): Execution timepremises_used(List[str]): Premises used in proofverification_details(VerificationDetails): Errors, warnings, sorry count
Example:
result = client.prove("∀ (n : ℕ), n + 0 = n")
print(result.lean_code)
search(query, k=10, use_tfidf_fallback=True)
Search mathlib4 premises.
Parameters:
query(str): Search queryk(int): Number of resultsuse_tfidf_fallback(bool): Use TF-IDF if FAISS fails
Returns: SearchResult
count(int): Number of resultssearch_method(str): "faiss" or "tfidf"premises(List[Premise]): Matching premises with similarity scores
Example:
result = client.search("Cauchy-Schwarz", k=5)
for premise in result.premises:
print(f"{premise.full_name}: {premise.similarity:.3f}")
verify(lean_code)
Verify LEAN 4 code compilation.
Parameters:
lean_code(str): LEAN code to verify
Returns: dict with errors, warnings, exit_code
Example:
code = "theorem test : 2 + 2 = 4 := by rfl"
result = client.verify(code)
solve(query, timeout=300.0)
Solve problem with multi-agent orchestration.
Parameters:
query(str): Problem descriptiontimeout(float): Timeout in seconds
Returns: SolveResult
success(bool): Whether problem was solvedsynthesis(str): Final synthesisexecution_time(float): Total timetask_results(List[TaskResult]): Individual task results
Example:
result = client.solve("Prove sqrt(2) is irrational and verify numerically")
print(result.synthesis)
get_usage()
Get usage statistics for your API key.
Returns: dict with request counts and quotas
Example:
usage = client.get_usage()
print(f"Daily requests: {usage['daily_requests']}/{usage['daily_limit']}")
Async API
All methods have async versions with a prefix:
import asyncio
from axmath_client import AxMath
async def main():
async with AxMath() as client:
# Async prove
result = await client.aprove("∀ n : ℕ, n + 0 = n")
# Async search
search_result = await client.asearch("Cauchy-Schwarz")
# Async solve
solve_result = await client.asolve("Prove sqrt(2) is irrational")
asyncio.run(main())
MCP Server (Claude Desktop)
Install with MCP support:
pip install axmath-client[mcp]
Configure in Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"axmath": {
"command": "axmath-mcp-server",
"env": {
"AXMATH_API_KEY": "axm_abc123..."
}
}
}
}
Then use in Claude Desktop:
- "Prove that n + 0 = n in LEAN 4"
- "Search mathlib for Cauchy-Schwarz inequality"
Error Handling
from axmath_client import (
AxMath,
AuthenticationError,
RateLimitError,
ServerError,
NetworkError,
)
try:
client = AxMath(api_key="invalid")
except AuthenticationError as e:
print(f"Auth failed: {e}")
try:
result = client.prove("theorem")
except RateLimitError as e:
print(f"Rate limit exceeded. Retry after {e.retry_after} seconds")
except ServerError as e:
print(f"Server error: {e}")
except NetworkError as e:
print(f"Network error: {e}")
Pricing Tiers
| Tier | Daily Requests | Monthly Requests | Price |
|---|---|---|---|
| Free | 100 | 3,000 | $0/month |
| Pro | 1,000 | 30,000 | $49/month |
| Enterprise | Unlimited | Unlimited | Custom |
Upgrade at: https://axmath.yourdomain.com/pricing
What Stays Private
The AxMath service (not included in this package):
- DeepSeek-Prover-V2 integration
- FAISS search implementation (180K premises)
- LEAN verification infrastructure
- Multi-agent orchestration
- Proprietary algorithms
This package only provides the API client to connect to the private service.
Support
- Documentation: https://axmath.yourdomain.com/docs
- API Reference: https://axmath.yourdomain.com/api/docs
- Issues: https://github.com/dirkenglund/math-physics-agents-dream-team/issues
License
MIT License - See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file axmath_client-1.0.0.tar.gz.
File metadata
- Download URL: axmath_client-1.0.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80d84411f933669d539dedfb597252be791e0bee29d10d43a90f77b210800532
|
|
| MD5 |
a432a0fcc2d30cf02a6fe993922c516d
|
|
| BLAKE2b-256 |
b80c228c4f0671e5f7158ac529fab6642256017a7874b7a95c283decb21be3d2
|
File details
Details for the file axmath_client-1.0.0-py3-none-any.whl.
File metadata
- Download URL: axmath_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a632374bc07d9278b62633d8163be5cd79260b574d8d4958f25fe0de92f4d084
|
|
| MD5 |
3e4c3e19c75e2dda677df0d114af73e4
|
|
| BLAKE2b-256 |
71ba6ea0d336108f6fc227aeef4f1dad9d8891ae74f4df4fe27ccdd0928310de
|