wellecks commited on
Commit
e18a867
1 Parent(s): a9ffbd0

minif2f isabelle

Browse files
Files changed (2) hide show
  1. README.md +50 -0
  2. minif2f_isabelle.py +160 -0
README.md CHANGED
@@ -1,3 +1,53 @@
1
  ---
2
  license: mit
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ tags:
4
+ - math
5
+ - theorem-proving
6
  ---
7
+
8
+ ## Dataset Description
9
+
10
+ - **Point of Contact:** [Sean Welleck](https://wellecks.com/)
11
+
12
+ # miniF2F+informal in Isabelle
13
+ [MiniF2F](https://arxiv.org/abs/2109.00110) is a formal mathematics benchmark (translated across multiple formal systems) consisting of
14
+ exercise statements from olympiads (AMC, AIME, IMO) as well as high-school and undergraduate maths
15
+ classes.
16
+
17
+ This dataset contains formal statements in Isabelle, each paired with an informal statement and
18
+ an informal proof as described in [Draft, Sketch, Prove [Jiang et al 2023]](https://openreview.net/forum?id=SMa9EAovKMC).
19
+
20
+ This dataset is derived from the latest [facebookresearch/miniF2F commit](https://github.com/facebookresearch/miniF2F/tree/5271ddec788677c815cf818a06f368ef6498a106) as of July 3, 2023.
21
+ Please see the repository for additional information.
22
+
23
+ ### Licensing Information
24
+
25
+ MIT
26
+
27
+ ### Citation Information
28
+
29
+ This dataset contains Isabelle problem statements from the miniF2F benchmark along with informal statements and proofs.
30
+
31
+ The initial version of miniF2F is described in [Zheng et al ICLR 2022](https://arxiv.org/abs/2109.00110):
32
+ ```
33
+ @inproceedings{zheng2022miniff,
34
+ title={miniF2F: a cross-system benchmark for formal Olympiad-level mathematics},
35
+ author={Kunhao Zheng and Jesse Michael Han and Stanislas Polu},
36
+ booktitle={International Conference on Learning Representations},
37
+ year={2022},
38
+ url={https://openreview.net/forum?id=9ZPegFuFTFv}
39
+ }
40
+ ```
41
+
42
+ The informal statements and proofs were curated and described in [Draft, Sketch, and Prove; Jiang et al ICLR 2023](https://openreview.net/forum?id=SMa9EAovKMC), along with significant fixes and improvements to the initial version of miniF2F:
43
+ ```
44
+ @inproceedings{jiang2023draft,
45
+ title={Draft, Sketch, and Prove: Guiding Formal Theorem Provers with Informal Proofs},
46
+ 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},
47
+ booktitle={The Eleventh International Conference on Learning Representations },
48
+ year={2023},
49
+ url={https://openreview.net/forum?id=SMa9EAovKMC}
50
+ }
51
+ ```
52
+
53
+
minif2f_isabelle.py ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """MiniF2F+Informal in Isabelle
16
+
17
+ Loading script author: Sean Welleck
18
+ """
19
+
20
+ import re
21
+ import glob
22
+ import json
23
+ import os
24
+ import datasets
25
+ from pathlib import Path
26
+
27
+
28
+ _CITATION = """\
29
+ @inproceedings{jiang2023draft,
30
+ title={Draft, Sketch, and Prove: Guiding Formal Theorem Provers with Informal Proofs},
31
+ 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},
32
+ booktitle={The Eleventh International Conference on Learning Representations },
33
+ year={2023},
34
+ url={https://openreview.net/forum?id=SMa9EAovKMC}
35
+ }
36
+
37
+ @inproceedings{zheng2022miniff,
38
+ title={miniF2F: a cross-system benchmark for formal Olympiad-level mathematics},
39
+ author={Kunhao Zheng and Jesse Michael Han and Stanislas Polu},
40
+ booktitle={International Conference on Learning Representations},
41
+ year={2022},
42
+ url={https://openreview.net/forum?id=9ZPegFuFTFv}
43
+ }
44
+ """
45
+
46
+ _DESCRIPTION = """\
47
+ 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.
48
+
49
+ This dataset contains formal statements in Isabelle. Each statement is paired with an informal statement and
50
+ an informal proof, as described in Draft, Sketch, Prove [Jiang et al 2023].
51
+
52
+ The problems in this dataset use the most recent facebookresearch/miniF2F commit on July 3, 2023.
53
+ """
54
+
55
+ _HOMEPAGE = "https://github.com/facebookresearch/miniF2F"
56
+ _LICENSE = "MIT"
57
+
58
+ _MINIF2F_COMMIT = '5271ddec788677c815cf818a06f368ef6498a106'
59
+ _URLS = {
60
+ "minif2f_repo": "https://github.com/facebookresearch/miniF2F/archive/%s.zip" % _MINIF2F_COMMIT
61
+ }
62
+
63
+ _ISABELLEDIR = 'miniF2F-%s/isabelle' % _MINIF2F_COMMIT
64
+ _INFORMALDIR = 'miniF2F-%s/informal' % _MINIF2F_COMMIT
65
+
66
+ _NAMES = [
67
+ 'miniF2F-isabelle-informal',
68
+ ]
69
+
70
+ VERSION = "1.1.0"
71
+
72
+
73
+ class MiniF2F(datasets.GeneratorBasedBuilder):
74
+ """MiniF2F+Informal in Isabelle"""
75
+
76
+ BUILDER_CONFIGS = [
77
+ datasets.BuilderConfig(name=name, version=VERSION, description=name) for name in _NAMES
78
+ ]
79
+
80
+ DEFAULT_CONFIG_NAME = "miniF2F-isabelle-informal"
81
+
82
+ def _info(self):
83
+ features = datasets.Features(
84
+ {
85
+ "problem_name": datasets.Value("string"),
86
+ "formal_statement": datasets.Value("string"),
87
+ "informal_statement": datasets.Value("string"),
88
+ "informal_proof": datasets.Value("string"),
89
+ "header": datasets.Value("string"),
90
+ }
91
+ )
92
+ return datasets.DatasetInfo(
93
+ description=_DESCRIPTION,
94
+ features=features,
95
+ homepage=_HOMEPAGE,
96
+ license=_LICENSE,
97
+ citation=_CITATION,
98
+ )
99
+
100
+ def _split_generators(self, dl_manager):
101
+ urls = _URLS
102
+ data_dir = dl_manager.download_and_extract(urls)
103
+
104
+ minif2f_repo_dir = data_dir['minif2f_repo']
105
+
106
+ def extract_theorem(text):
107
+ extract = re.findall(r"(theorem.*?:.*?(?=by |using |proof|sorry))[\s]*", text, re.DOTALL)[0].strip()
108
+ assert extract != ''
109
+ return extract
110
+
111
+ def extract_header(text):
112
+ extract = re.findall(r"(.*?)theorem.*?", text, re.DOTALL)[0]
113
+ assert extract != ''
114
+ return extract
115
+
116
+ splits = {'valid': [], 'test': []}
117
+ for split in ['valid', 'test']:
118
+ for f in glob.glob(
119
+ os.path.join(minif2f_repo_dir, _ISABELLEDIR, '%s/*.thy' % split)
120
+ ):
121
+ text = open(f).read()
122
+ name = Path(f).name.replace('.thy', '')
123
+ thm = extract_theorem(text)
124
+ header = extract_header(text)
125
+ informal = json.load(open(
126
+ os.path.join(minif2f_repo_dir, _INFORMALDIR, '%s/%s.json' % (split, name))
127
+ ))
128
+
129
+ splits[split].append({
130
+ 'problem_name': name,
131
+ 'formal_statement': thm,
132
+ 'informal_statement': informal['informal_statement'],
133
+ 'informal_proof': informal['informal_proof'],
134
+ 'header': header
135
+ })
136
+
137
+ assert len(splits['valid']) == 244
138
+ assert len(splits['test']) == 244
139
+
140
+ return [
141
+ datasets.SplitGenerator(
142
+ name=datasets.Split.VALIDATION,
143
+ gen_kwargs={
144
+ "split": "valid",
145
+ "examples": splits['valid']
146
+ },
147
+ ),
148
+ datasets.SplitGenerator(
149
+ name=datasets.Split.TEST,
150
+ gen_kwargs={
151
+ "split": "test",
152
+ "examples": splits['test']
153
+ },
154
+ ),
155
+ ]
156
+
157
+ def _generate_examples(self, split, examples):
158
+ for example in examples:
159
+ key = example["problem_name"]
160
+ yield key, example