Skip to content

Add Erdős benchmark suite: 1,183 problems with ground truth and expert context - #3

Open
JunjieAraoXiong wants to merge 3 commits into
T3S1AMAX:mainfrom
JunjieAraoXiong:benchmark-erdos
Open

Add Erdős benchmark suite: 1,183 problems with ground truth and expert context#3
JunjieAraoXiong wants to merge 3 commits into
T3S1AMAX:mainfrom
JunjieAraoXiong:benchmark-erdos

Conversation

@JunjieAraoXiong

Copy link
Copy Markdown

Summary

Comprehensive benchmark suite for evaluating automated theorem provers on Erdős problems.

Data sources integrated

Source Count What it provides
Tao's erdosproblems database 1,183 Status, tags, prize, formalization state
gpt-erdos 675 LaTeX statements + GPT-5.2 Pro candidate proofs
DeepMind formal-conjectures 387 Ground truth Lean 4 formalizations
erdosproblems.com forum 366 comments Expert discussions including 43 from Terence Tao

Tools

  • run_benchmark.py — benchmark runner with GPT-erdos comparison mode
  • autoresearch_erdos.py — standalone autoresearch loop (subprocess-based)
  • build_erdos_corpus.py — corpus builder merging all 4 data sources
  • integrate_formal_conjectures.py — matches DeepMind Lean files to corpus
  • scrape_top_comments.py — forum comment scraper

Hand-picked problems (9)

Tier 1 (in Mathlib, test retrieval): Erdős-Szekeres, Erdős-Ko-Rado, Erdős-Ginzburg-Ziv, Bertrand's postulate, ∑1/p diverges, primes ≡3 mod 4

Tier 2 (not in Mathlib, test proving): Ramsey R(3,3)=6, Erdős-Gallai, Erdős-Mordell

Benchmark runner features

  • MathCode binary mode (--use-mathcode) and AUTOLEAN API mode
  • GPT-erdos comparison table (--gpt-erdos-solutions)
  • Ground truth verification (checks for DeepMind Lean files)
  • Filter by tier, tags
  • JSON + markdown output

Test plan

  • Corpus builds successfully (1,183 problems)
  • 387/387 DeepMind Lean files matched
  • Comment scraping works (87 comments on #728)
  • Full benchmark run on Tier 1 problems

Tier 1 (in Mathlib, test retrieval): Erdős-Szekeres, Erdős-Ko-Rado,
Erdős-Ginzburg-Ziv, Bertrand's postulate, ∑1/p diverges, primes ≡3 mod 4

Tier 2 (not in Mathlib, test proving): Ramsey R(3,3)=6, Erdős-Gallai,
Erdős-Mordell inequality

Runner supports MathCode binary mode and AUTOLEAN Python API mode,
outputs JSON + markdown summary tables.
- build_erdos_corpus.py: merges 3 data sources:
  1. Tao's erdosproblems GitHub (problems.yaml) — metadata, tags, status
  2. gpt-erdos dataset (unsolved.jsonl) — LaTeX problem statements
  3. gpt-erdos solutions/ — GPT 5.2 Pro candidate proofs + Lean files
  4. erdosproblems.com forum threads — expert discussions incl Tao's comments

- convert_erdos_dataset.py: simpler converter for gpt-erdos JSONL only

- Full corpus: 1183 problems, 675 with LaTeX, 387 formalized on site
- Comment scraper: working on forum threads (87 comments on #728, 10 from Tao)
- Filter by tags, status, problem numbers
Data integration:
- 1183 Erdős problems from Tao's database + gpt-erdos LaTeX
- 387 DeepMind formal-conjectures Lean files matched to corpus
- 366 expert comments scraped (43 from Tao across 13 problems)
- GPT-5.2 Pro candidate proofs from gpt-erdos for comparison

New tools:
- integrate_formal_conjectures.py: match DeepMind Lean files to corpus
- scrape_top_comments.py: scrape erdosproblems.com forum discussions
- build_erdos_corpus.py: merge all data sources into unified corpus
- convert_erdos_dataset.py: simpler gpt-erdos JSONL converter

Benchmark runner updates:
- GPT-erdos comparison mode (--gpt-erdos-solutions)
- Side-by-side table: Our Prover vs GPT-5.2+Aristotle vs Ground Truth

Autoresearch loop:
- autoresearch_erdos.py: autonomous proving loop (karpathy-inspired)
- 4 strategies: direct, retrieval, decomposition, expert
- Resume support, live logging, per-problem time budget
- Summary generation with by-strategy and by-tag breakdowns

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces scripts to build and convert an Erdős problem corpus for benchmarking, along with an autoresearch loop for proving these problems using an external binary. The code changes are functional and well-structured. I have provided feedback on improving the robustness of subprocess command parsing using shlex, ensuring safe timeout values, and improving the LaTeX-to-text conversion and data persistence logic to avoid unnecessary truncation of mathematical content.

import argparse
import json
import random
import subprocess

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider importing shlex to safely parse the mathcode_cmd string, especially if it contains paths with spaces or multiple arguments.

Suggested change
import subprocess
import shlex
import subprocess


start = time.monotonic()
try:
cmd_parts = mathcode_cmd.split()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using split() on a command string is fragile as it fails if the path to the binary contains spaces. shlex.split() is the standard way to handle this.

Suggested change
cmd_parts = mathcode_cmd.split()
cmd_parts = shlex.split(mathcode_cmd)

)
break

strategy_timeout = min(int(remaining), max_time_per_problem)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If remaining is less than 1 second, int(remaining) will be 0. Passing a timeout of 0 to subprocess.run might lead to immediate timeouts or unexpected behavior. It's safer to ensure a minimum timeout of at least 1 second.

Suggested change
strategy_timeout = min(int(remaining), max_time_per_problem)
strategy_timeout = max(1, min(int(remaining), max_time_per_problem))

Comment on lines +48 to +50
text = re.sub(r'\\\[', '', text)
text = re.sub(r'\\\]', '', text)
text = re.sub(r'\$\$', '', text)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Removing LaTeX display math delimiters without replacing them with a space causes adjacent words to merge (e.g., then\[N becomes thenN). This degrades the quality of the generated problem statements.

Suggested change
text = re.sub(r'\\\[', '', text)
text = re.sub(r'\\\]', '', text)
text = re.sub(r'\$\$', '', text)
text = re.sub(r'\\\\[', ' ', text)
text = re.sub(r'\\\\]', ' ', text)
text = re.sub(r'\\$\\\$', ' ', text)

Comment on lines +128 to +129
except Exception:
return []

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Catching all exceptions silently here makes it difficult to diagnose issues like network failures or changes in the website's structure. Consider logging the error or catching more specific exceptions.

author = meta.split(sep)[0].strip()
break
if body:
self.results.append({"author": author, "text": body[:1000]})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Truncating expert comments to 1000 characters may cut off significant mathematical context and reasoning, which is a key part of this benchmark suite. Consider removing this limit.

Suggested change
self.results.append({"author": author, "text": body[:1000]})
self.results.append({"author": author, "text": body})

stats["has_lean"] += 1
if md_path.exists():
md_text = md_path.read_text(encoding="utf-8")
record["reference_proof_hint"] = md_text[:1000]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Truncating proof hints to 1000 characters might remove essential parts of the candidate solutions. Since these are intended for expert context and evaluation, it's better to preserve the full text.

Suggested change
record["reference_proof_hint"] = md_text[:1000]
record["reference_proof_hint"] = md_text

Comment on lines +49 to +51
text = re.sub(r'\\\[', '', text)
text = re.sub(r'\\\]', '', text)
text = re.sub(r'\$\$', '', text)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Removing LaTeX delimiters without adding a space leads to merged words (e.g., is$$\sum becomes is\sum). Replacing them with a space ensures the text remains readable for LLMs.

Suggested change
text = re.sub(r'\\\[', '', text)
text = re.sub(r'\\\]', '', text)
text = re.sub(r'\$\$', '', text)
text = re.sub(r'\\\\[', ' ', text)
text = re.sub(r'\\\\]', ' ', text)
text = re.sub(r'\\$\\\$', ' ', text)

if md_path.exists():
# Store first 500 chars as hint
md_text = md_path.read_text(encoding="utf-8")
autolean_json["reference_proof_hint"] = md_text[:500]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Truncating proof hints to 500 characters is very restrictive and likely removes the most useful parts of the candidate proofs. It's better to include the full text.

Suggested change
autolean_json["reference_proof_hint"] = md_text[:500]
autolean_json["reference_proof_hint"] = md_text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant