Download generator/render.py from davinci-prover/agentic-prover-RL-env: direct link, hf CLI and curl.
- Browser
- Download file 7.06 kB
-
https://huggingface.co/datasets/davinci-prover/agentic-prover-RL-env/resolve/main/generator/render.py
- Command line
-
hf download hf://datasets/davinci-prover/agentic-prover-RL-env/generator/render.py
-
curl -L -o render.py https://huggingface.co/datasets/davinci-prover/agentic-prover-RL-env/resolve/main/generator/render.py
7.06 kB
| #!/usr/bin/env python3 | |
| """Render task-only Parquet rows as self-contained FineEnvs-style tasks. | |
| Requires pyarrow. Does not load successful trajectories or reference proofs. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import hashlib | |
| import json | |
| import re | |
| import shutil | |
| from collections import Counter | |
| from pathlib import Path | |
| import pyarrow as pa | |
| import pyarrow.parquet as pq | |
| SOURCE = "davinci-prover/agentic-prover-RL" | |
| REVISION = "fe15df9eceb1162c74683d92f230206d16a39487" | |
| LEAN = "leanprover/lean4:v4.35.0" | |
| MATHLIB = "56a005855ea17e0b0958f73ec801ae140b0a1679" | |
| AXIOMS = ["propext", "Quot.sound", "Classical.choice"] | |
| def write_json(path: Path, obj) -> None: | |
| path.parent.mkdir(parents=True, exist_ok=True) | |
| path.write_text(json.dumps(obj, ensure_ascii=False, indent=2) + "\n") | |
| def instruction(row: dict) -> str: | |
| names = ", ".join(f"`{n}`" for n in row["theorem_names"]) | |
| return f"""# Prove the Lean theorem | |
| Complete the proof of {names}. The original task source is available at | |
| `/workspace/Challenge.lean`: | |
| ```lean | |
| {row['theorem_statement']} | |
| ``` | |
| Lean 4.35.0 and Mathlib at `{MATHLIB}` are preinstalled. | |
| `/workspace` is a configured Lake project. Start with: | |
| ```bash | |
| cp /workspace/Challenge.lean /workspace/Submission.lean | |
| ``` | |
| Replace the proof holes with complete proofs. Preserve the original declaration | |
| names, namespaces, hypotheses, conclusions, and all definitions used by the | |
| statement. Do not weaken the statement or change fixed definitions. | |
| Do not use `sorry`, `admit`, `native_decide`, or introduce new axioms. The final | |
| proof may depend only on `propext`, `Quot.sound`, and `Classical.choice` as axioms. | |
| You may use ordinary Lean tactics and the installed Mathlib library. | |
| You may add helper lemmas and instances after the original definitions, or put | |
| them in `Submission/**/*.lean` modules imported by `Submission.lean`. Only the | |
| regular source files `/workspace/Submission.lean` and `/workspace/Submission/**/*.lean` | |
| are collected. Changes to the toolchain, Mathlib, Lake configuration, and files | |
| outside those submission paths are not part of the submission. | |
| Work offline using the supplied files and installed libraries. Do not search | |
| the web, download proofs or packages, or contact external services for answers. | |
| Any model API connection is reserved for the harness, not agent tools. | |
| Check your proof with: | |
| ```bash | |
| cd /workspace && lake build Submission | |
| ``` | |
| Use `#print axioms <fully-qualified theorem name>` to inspect dependencies. | |
| Compilation with `sorry` warnings is not a completed proof. After checking, | |
| save the source files and finish. An independent verifier checks the original | |
| statement, axiom dependencies, and Lean kernel replay. Your final chat response | |
| is not the graded submission. | |
| """ | |
| def task_toml(row: dict) -> str: | |
| q = lambda value: json.dumps(value, ensure_ascii=False) | |
| return f'''schema_version = "1.4" | |
| [task] | |
| name = {q("agentic-prover-RL-env/" + row["task_id"])} | |
| version = "1.0.0" | |
| description = "Complete a Lean 4.35.0 theorem proof; checked by the native comparator in a separate offline environment." | |
| keywords = ["lean4", "mathlib", "theorem-proving", "agentic-prover"] | |
| [metadata] | |
| task_id = {q(row["task_id"])} | |
| source_dataset = {q(SOURCE)} | |
| source_revision = {q(REVISION)} | |
| source = {q(row["source"])} | |
| source_id = {q(row["source_id"])} | |
| source_license = {q(row["source_license"] or "unspecified")} | |
| difficulty = {q(row["difficulty"])} | |
| theorems = {q(row["theorem_names"])} | |
| definition_holes = [] | |
| lean_toolchain = {q(LEAN)} | |
| mathlib_commit = {q(MATHLIB)} | |
| statement_sha256 = {q(row["statement_sha256"])} | |
| [agent] | |
| timeout_sec = 3600 | |
| network_mode = "no-network" | |
| [environment] | |
| build_timeout_sec = 5400 | |
| cpus = 2 | |
| memory_mb = 16384 | |
| storage_mb = 10240 | |
| workdir = "/workspace" | |
| env = {{ LEAN_NUM_THREADS = "2" }} | |
| [verifier] | |
| timeout_sec = 1200 | |
| environment_mode = "separate" | |
| network_mode = "no-network" | |
| [[verifier.collect]] | |
| command = "python3 /opt/davinci-prover/pack_submission.py" | |
| timeout_sec = 300 | |
| ''' | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[1]) | |
| args = parser.parse_args() | |
| root = args.root.resolve() | |
| rows = pq.read_table(root / "data/train.parquet").to_pylist() | |
| templates = root / "generator/templates" | |
| seen = set() | |
| index = [] | |
| for row in rows: | |
| task_id = row["task_id"] | |
| if not re.fullmatch(r"[A-Za-z0-9_][A-Za-z0-9_.-]*", task_id) or task_id in seen: | |
| raise ValueError(f"unsafe or duplicate task id: {task_id}") | |
| seen.add(task_id) | |
| statement = row["theorem_statement"] | |
| digest = hashlib.sha256(statement.encode()).hexdigest() | |
| assert row["statement_sha256"] == digest | |
| assert row["task_type"] == "lean_theorem_proving" | |
| assert row["target_workspace"]["toolchain"] == LEAN | |
| assert row["target_workspace"]["commit_hash"] == MATHLIB | |
| assert row["theorem_names"] and len(set(row["theorem_names"])) == len(row["theorem_names"]) | |
| task = root / "tasks" / task_id | |
| env = task / "environment" | |
| tests = task / "tests" | |
| env.mkdir(parents=True, exist_ok=True) | |
| tests.mkdir(parents=True, exist_ok=True) | |
| (task / "instruction.md").write_text(instruction(row)) | |
| (task / "task.toml").write_text(task_toml(row)) | |
| for directory in (env, tests): | |
| (directory / "Challenge.lean").write_text(statement) | |
| shutil.copyfile(templates / "Dockerfile", env / "Dockerfile") | |
| for name in ("grade.py", "capture_bwrap.py", "normalize_matchers.py", "test.sh"): | |
| shutil.copyfile(templates / name, tests / name) | |
| (tests / name).chmod(0o755) | |
| write_json(tests / "task.json", { | |
| "challenge": task_id, | |
| "grade_timeout_sec": 1100, | |
| "comparator": { | |
| "theorem_names": row["theorem_names"], | |
| "definition_names": [], | |
| "permitted_axioms": AXIOMS, | |
| }, | |
| }) | |
| index.append({k: row[k] for k in ( | |
| "task_id", "task_path", "theorem_names", "statement_sha256", | |
| "difficulty", "source", "source_id", "source_license", | |
| )}) | |
| write_json(root / "registry.json", [{ | |
| "name": "agentic-prover-RL-env", "version": "1.0", | |
| "description": "4030 Lean 4.35 proof environments; no trajectories or reference submissions.", | |
| "tasks": [{"name": r["task_id"], "path": r["task_path"]} for r in rows], | |
| }]) | |
| write_json(root / "manifest.json", { | |
| "source": SOURCE, "source_commit": REVISION, | |
| "lean_toolchain": LEAN, "mathlib_commit": MATHLIB, | |
| "tasks": index, "excluded": [], | |
| "validation": "See validation/report.json; preserved source proofs were not republished.", | |
| }) | |
| pq.write_table(pa.Table.from_pylist(index), root / "manifest.parquet", compression="zstd") | |
| print(json.dumps({"tasks": len(rows), "difficulty": dict(Counter(r["difficulty"] for r in rows))})) | |
| if __name__ == "__main__": | |
| main() | |