AI for Math project: Discrete maths autoformalization with hypothesis decomposition
Jupyter Notebook
1
64 commits
updated Mar 4, 2025
This repository contains the code and data for a semester project on autoformalization of discrete math statements in Lean 4.
The project report contains a detailed discussion of:
data/
Curated datasets of informal–formal pairs, retrieval corpus, and the code used to create them
pdfs/
Final report and figures. Refer to this for a detailed explanation of the project’s methodology, experiments, and findings
repl/
Submodule used for the type-checking evaluation
results/
checkpoints/ the Lean server crashes easily, so we save our progress in evalsevaluations/ detailed evaluation results, including type-checking, TC-BLEU, and BEq scoresgenerations/ raw outputs from our different methodsAll key settings—API keys, datasets, generation methods, and paths—are controlled in config.py.
METHOD = None : direct translation baselineMETHOD = 'informal_decomp' : adds the informal hypothesis decomposition stepMETHOD = 'leandojo' : proof state-based retrievalMETHOD = 'leansearch' : semantic search retrievalYou can further adjust:
FEWSHOT: whether to include few-shot examples in the promptDATASET_NAME: Hugging Face dataset for evaluationDEFAULT_MODEL: base modelAfter editing config.py to your liking, you can generate formal statements by running:
python generation.py
Two evaluation steps are available:
Type Checking & BLEU
python eval.py
BEq (Bidirectional Equivalence)
python beq_eval_cpu.py
This eval is designed to run on CPU but can be intensive, adjust NB_PROCESS inside the script depending on your setup.
Use the notebook results_analysis.ipynb to visualize key metrics, method complementarities, and more.
Happy autoformalizing !
AI for Math project: Discrete maths autoformalization with hypothesis decomposition
Jupyter Notebook
1
64 commits
updated Mar 4, 2025
This repository contains the code and data for a semester project on autoformalization of discrete math statements in Lean 4.
The project report contains a detailed discussion of:
data/
Curated datasets of informal–formal pairs, retrieval corpus, and the code used to create them
pdfs/
Final report and figures. Refer to this for a detailed explanation of the project’s methodology, experiments, and findings
repl/
Submodule used for the type-checking evaluation
results/
checkpoints/ the Lean server crashes easily, so we save our progress in evalsevaluations/ detailed evaluation results, including type-checking, TC-BLEU, and BEq scoresgenerations/ raw outputs from our different methodsAll key settings—API keys, datasets, generation methods, and paths—are controlled in config.py.
METHOD = None : direct translation baselineMETHOD = 'informal_decomp' : adds the informal hypothesis decomposition stepMETHOD = 'leandojo' : proof state-based retrievalMETHOD = 'leansearch' : semantic search retrievalYou can further adjust:
FEWSHOT: whether to include few-shot examples in the promptDATASET_NAME: Hugging Face dataset for evaluationDEFAULT_MODEL: base modelAfter editing config.py to your liking, you can generate formal statements by running:
python generation.py
Two evaluation steps are available:
Type Checking & BLEU
python eval.py
BEq (Bidirectional Equivalence)
python beq_eval_cpu.py
This eval is designed to run on CPU but can be intensive, adjust NB_PROCESS inside the script depending on your setup.
Use the notebook results_analysis.ipynb to visualize key metrics, method complementarities, and more.
Happy autoformalizing !