|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""MiniF2F+Informal in Isabelle |
|
Loading script author: Sean Welleck |
|
""" |
|
|
|
import re |
|
import glob |
|
import json |
|
import os |
|
import datasets |
|
from pathlib import Path |
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{jiang2023draft, |
|
title={Draft, Sketch, and Prove: Guiding Formal Theorem Provers with Informal Proofs}, |
|
author={Albert Qiaochu Jiang and Sean Welleck and Jin Peng Zhou and Timothee Lacroix and Jiacheng Liu and Wenda Li and Mateja Jamnik and Guillaume Lample and Yuhuai Wu}, |
|
booktitle={The Eleventh International Conference on Learning Representations }, |
|
year={2023}, |
|
url={https://openreview.net/forum?id=SMa9EAovKMC} |
|
} |
|
@inproceedings{zheng2022miniff, |
|
title={miniF2F: a cross-system benchmark for formal Olympiad-level mathematics}, |
|
author={Kunhao Zheng and Jesse Michael Han and Stanislas Polu}, |
|
booktitle={International Conference on Learning Representations}, |
|
year={2022}, |
|
url={https://openreview.net/forum?id=9ZPegFuFTFv} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
MiniF2F is a formal mathematics benchmark (translated across multiple formal systems) consisting of exercise statements from olympiads (AMC, AIME, IMO) as well as high-school and undergraduate maths classes. |
|
This dataset contains formal statements in Isabelle. Each statement is paired with an informal statement and |
|
an informal proof, as described in Draft, Sketch, Prove [Jiang et al 2023]. |
|
The problems in this dataset use the most recent facebookresearch/miniF2F commit on July 3, 2023. |
|
""" |
|
|
|
|
|
_HOMEPAGE = "https://github.com/xyc-cs/miniF2F" |
|
_LICENSE = "MIT" |
|
|
|
|
|
_MINIF2F_COMMIT = '0826c5173d8b2ef67c616a8170240034094837d6' |
|
|
|
_URLS = { |
|
"minif2f_repo": "https://github.com/xyc-cs/miniF2F/archive/%s.zip" % _MINIF2F_COMMIT |
|
} |
|
|
|
_ISABELLEDIR = 'miniF2F-%s/isabelle' % _MINIF2F_COMMIT |
|
_INFORMALDIR = 'miniF2F-%s/informal' % _MINIF2F_COMMIT |
|
|
|
_NAMES = [ |
|
'miniF2F-isabelle-informal', |
|
] |
|
|
|
VERSION = "1.1.0" |
|
|
|
|
|
class MiniF2F(datasets.GeneratorBasedBuilder): |
|
"""MiniF2F+Informal in Isabelle""" |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name=name, version=VERSION, description=name) for name in _NAMES |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "miniF2F-isabelle-informal" |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"problem_name": datasets.Value("string"), |
|
"formal_statement": datasets.Value("string"), |
|
"informal_statement": datasets.Value("string"), |
|
"informal_discuss": datasets.Value("string"), |
|
"header": datasets.Value("string"), |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
urls = _URLS |
|
data_dir = dl_manager.download_and_extract(urls) |
|
|
|
minif2f_repo_dir = data_dir['minif2f_repo'] |
|
|
|
def extract_theorem(text): |
|
|
|
|
|
extract = '' |
|
return extract |
|
|
|
def extract_header(text): |
|
|
|
|
|
extract = '' |
|
return extract |
|
|
|
splits = {'valid': [], 'test': []} |
|
for split in ['valid', 'test']: |
|
for f in glob.glob( |
|
os.path.join(minif2f_repo_dir, _ISABELLEDIR, '%s/*.json' % split) |
|
): |
|
text = open(f).read() |
|
name = Path(f).name.replace('.json', '') |
|
thm = extract_theorem(text) |
|
header = extract_header(text) |
|
informal = json.load(open( |
|
os.path.join(minif2f_repo_dir, _INFORMALDIR, '%s/%s.json' % (split, name)) |
|
)) |
|
|
|
splits[split].append({ |
|
'problem_name': name, |
|
'formal_statement': thm, |
|
'informal_statement': informal['informal_statement'], |
|
'informal_discuss': informal['informal_discuss'] |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
gen_kwargs={ |
|
"split": "valid", |
|
"examples": splits['valid'] |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
gen_kwargs={ |
|
"split": "test", |
|
"examples": splits['test'] |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, split, examples): |
|
for example in examples: |
|
key = example["problem_name"] |
|
yield key, example |