Semantic search over Mathlib and Tau Ceti. Send a query, get back ranked Lean declarations.
POST https://lean-lsp-proxy.leanfinder.workers.dev
No API key needed. Send a JSON body with Content-Type: application/json.
Rate limit: 5 requests per 10 seconds per IP. Over the limit you get HTTP 429 with a Retry-After header; wait that many seconds and retry.
| Field | Type | Description |
|---|---|---|
inputs | string | Required. Your query text. |
top_k | int | Number of results. Default 10. |
lib | string | Library to search: mathlib (default) or tauceti. |
version | string | Index version. Mathlib: v4.19.0, v4.24.0 or v4.28.0 (default). Tau Ceti: v4.35.0-rc3 (default). Match your project so returned names exist in your build. |
inputs can be an informal statement, a question about Lean or Mathlib, a pasted proof state, or a rough Lean snippet.
{
"inputs": "continuous function on a compact set is bounded above",
"top_k": 5,
"version": "v4.28.0"
}
Add "lib": "tauceti" to the request. You can leave out version; it defaults to v4.35.0-rc3.
{
"inputs": "continuous function on a compact set is bounded above",
"top_k": 5,
"lib": "tauceti"
}
Results have the same fields as Mathlib results, and url links to the Tau Ceti docs.
A results array, most relevant first.
{
"results": [
{
"formal_name": "IsCompact.bddAbove_image",
"informal_name": "Continuous Image of Compact Set is Bounded Above ...",
"kind": "theorem",
"type": "...",
"informal_description": "...",
"path": "Mathlib/Topology/Order/Compact",
"url": "https://leanprover-community.github.io/mathlib4_docs/find/?pattern=IsCompact.bddAbove_image#doc",
"score": 0.0
}
]
}
| Field | Meaning |
|---|---|
formal_name | Lean declaration name. |
informal_name | Short natural-language name. |
kind | theorem, def, structure, instance, ... |
type | Lean type signature. |
informal_description | Natural-language description. |
path | Module path; the file is <path>.lean in the library. |
url | Link to the declaration in the Mathlib or Tau Ceti docs. |
score | Always 0, kept for backward compatibility. Use the order of results instead. |
{"error": "..."}. A missing inputs returns HTTP 400; an unknown lib or version returns HTTP 200 with an error key, so check for it.curl https://lean-lsp-proxy.leanfinder.workers.dev \
-H "Content-Type: application/json" \
-d '{"inputs": "continuous function on a compact set is bounded above", "top_k": 5, "version": "v4.28.0"}'
# Tau Ceti
curl https://lean-lsp-proxy.leanfinder.workers.dev \
-H "Content-Type: application/json" \
-d '{"inputs": "continuous function on a compact set is bounded above", "top_k": 5, "lib": "tauceti"}'
import requests
ENDPOINT = "https://lean-lsp-proxy.leanfinder.workers.dev"
def lean_finder(query, top_k=5, lib="mathlib", version=None):
payload = {"inputs": query, "top_k": top_k, "lib": lib}
if version: # omit to use the library's default version
payload["version"] = version
resp = requests.post(ENDPOINT, json=payload, timeout=60)
resp.raise_for_status()
return resp.json().get("results", [])
for r in lean_finder("continuous function on a compact set is bounded above"):
print(r["formal_name"])
for r in lean_finder("continuous function on a compact set is bounded above", lib="tauceti"):
print(r["formal_name"])
The backend scales to zero when idle. The first request after a quiet period may fail or return 503 for 1 to 2 minutes while the model loads. Retry until it responds.
import time
def lean_finder_retry(query, max_wait=300, **kwargs):
start = time.time()
while True:
try:
return lean_finder(query, **kwargs)
except requests.exceptions.RequestException:
if time.time() - start > max_wait:
raise
time.sleep(5)