faithcheck 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,17 @@
1
+ misformal-bench and faithcheck
2
+ Code: Apache License 2.0 (see LICENSE).
3
+
4
+ The dataset in data/ is derived from the public git histories of the
5
+ following projects. Each row keeps the source repository, commit hash and
6
+ file path so it can be traced back. Lean statements in each row remain under
7
+ the license of the project they came from:
8
+
9
+ - google-deepmind/formal-conjectures Apache License 2.0
10
+ - trishullab/PutnamBench (lean4/) Apache License 2.0
11
+ - dwrensha/compfiles Apache License 2.0
12
+ - yangky11/miniF2F-lean4 MIT License, Copyright (c) Meta Platforms, Inc. and affiliates.
13
+
14
+ PutnamBench's English (informal) problem statements are published by
15
+ PutnamBench with permission from the Mathematical Association of America.
16
+ They are NOT redistributed here: the `english` field of PutnamBench rows is
17
+ empty, and scripts/fill_english.py fills it from your own PutnamBench clone.
@@ -0,0 +1,216 @@
1
+ Metadata-Version: 2.4
2
+ Name: faithcheck
3
+ Version: 0.1.1
4
+ Summary: Flag Lean 4 theorem statements that may not say what their English says
5
+ Author: misformal-bench contributors
6
+ License-Expression: Apache-2.0
7
+ Keywords: lean,lean4,formal verification,autoformalization,mathlib,benchmark
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest>=7; extra == "dev"
16
+ Dynamic: license-file
17
+
18
+ # misformal-bench + faithcheck
19
+
20
+ **A Lean proof only certifies the Lean statement.** If the statement does not
21
+ say what the English problem says, a correct proof proves the wrong thing.
22
+ This repo is about that gap between English and Lean.
23
+
24
+ It has two parts:
25
+
26
+ - **misformal-bench**: 1,342 real misformalizations, mined from the fix
27
+ histories of four public Lean benchmarks. Each row is
28
+ *(English, wrong Lean statement, fixed Lean statement, commit)*.
29
+ - **faithcheck**: a pip-installable checker, plus a GitHub Action, that flags
30
+ Lean statements that may not match their English.
31
+
32
+ ## misformal-bench v0
33
+
34
+ | | rows | statement fixes | definition fixes | core statement fixes |
35
+ |---|---:|---:|---:|---:|
36
+ | formal-conjectures | 567 | 474 | 93 | 381 |
37
+ | PutnamBench | 717 | 687 | 30 | 177 |
38
+ | compfiles | 38 | 25 | 13 | 25 |
39
+ | miniF2F (Lean 4) | 20 | 20 | 0 | 20 |
40
+ | **total** | **1,342** | **1,206** | **136** | **603** |
41
+
42
+ Commits run from 2023-10-18 to 2026-06-29 (445 commits). Fixes committed
43
+ on or after 2026-07-01 are kept back as a private, held-out test set, so
44
+ scores on it cannot be inflated by training on it. `data/stats.json` has
45
+ the exact counts.
46
+
47
+ ### How rows are mined
48
+
49
+ `scripts/mine_history.py` walks each repository's history. It keeps a commit
50
+ when the commit message reads like a fix (fix, misformalization, correct,
51
+ wrong, typo, and similar) and is not about lint, build, imports, a toolchain
52
+ bump, renaming or style. For every theorem whose **statement** changed in
53
+ such a commit, it records the old and new statement. Comments and all
54
+ whitespace are ignored when comparing, so reformatting alone does not count.
55
+ Definition changes are tier `B_definition_fix`. Those rows list the theorems
56
+ that mention the definition in `dependents`.
57
+
58
+ ### Row fields
59
+
60
+ | field | meaning |
61
+ |---|---|
62
+ | `english` | docstring above the declaration (or the file's module docstring for compfiles) *before* the fix. Empty for PutnamBench, see below |
63
+ | `stmt_old`, `stmt_new` | signature (binders + type) before and after, comments stripped, whitespace normalised |
64
+ | `body_old`, `body_new` | for definition fixes only |
65
+ | `tier` | `A_statement_fix` or `B_definition_fix` |
66
+ | `core` | `false` for rows from commits that touch 10 or more declarations (mass migrations such as PutnamBench's optParam fix) and for pure `answer(sorry)` → `answer(True)` status updates |
67
+ | `doc_changed` | the English changed in the same commit. Sometimes the English was the thing that was wrong |
68
+ | `refixed_later` | the same declaration was fixed again later, so `stmt_new` is not final ground truth |
69
+ | `commit`, `commit_subject`, `commit_body`, `date`, `file`, `source` | provenance |
70
+ | `text_tags` | keyword tags from the commit message (slicing only, not labels) |
71
+
72
+ ### Known limits (read before using it for evaluation)
73
+
74
+ - **No row has been compiled.** These are statements as committed, against
75
+ whatever Mathlib each repository used at the time.
76
+ - **Precision is not 100%.** Some fix-labelled commits also carry refactors
77
+ or syntax changes. In a hand check of 30 random `core` statement rows
78
+ (seed 2026), 25 were clear semantic fixes, 3 were unclear (large rewrites)
79
+ and 2 were noise (`∈` → `in` syntax, a namespace qualifier). Treat `core`
80
+ rows as roughly 85–90% real fixes.
81
+ - **There is no positive (faithful) class.** Statements that stayed
82
+ unchanged for a long time are a reasonable source of negatives, but they
83
+ are not included.
84
+ - **PutnamBench English is not redistributed** (it is published with
85
+ permission from the MAA). Clone PutnamBench and run
86
+ `python scripts/fill_english.py data/misformal_bench_v0.jsonl /path/to/PutnamBench filled.jsonl`.
87
+ That fills 690 of 717 PutnamBench rows.
88
+
89
+ ## faithcheck
90
+
91
+ ```bash
92
+ pip install faithcheck # or: pip install -e . from this repo
93
+ faithcheck lint path/to/Project/ # static lints, no Lean needed
94
+ faithcheck lint --info --format github MyProblems/ # include smells, GitHub annotations
95
+ ```
96
+
97
+ ### Static lints (no Lean needed)
98
+
99
+ | lint | level | what it flags |
100
+ |---|---|---|
101
+ | `optparam_binder` | warning | `(x : T := v)` in a theorem. The theorem is still quantified over **every** `x`, so the default constrains nothing. This was PutnamBench's largest single bug class (218 statements fixed in one commit) |
102
+ | `sorry_in_statement` | warning | `sorry` inside the statement itself (`answer(sorry)` is allowed) |
103
+ | `nat_fraction_exponent` | warning | `x ^ (1 / 3)`: the exponent is a natural number, so `1 / 3 = 0` and the power is 1. Found by the Lean vacuity check on miniF2F (see below) |
104
+ | `nat_subtraction` | info | `a - b` on ℕ outside a cast, which truncates at 0 |
105
+ | `int_division` | info | `a / b` on ℕ/ℤ, which is floor division, and `x / 0 = 0` |
106
+ | `positivity_missing` | info | the English calls `n` a positive integer, `n : ℕ`, and nothing rules out `n = 0` |
107
+ | `type_mismatch` | info | the English says real numbers but the statement has only ℕ/ℤ, or the reverse |
108
+ | `range_from_zero` | info | `Finset.range n` (which is `{0, …, n-1}`) while the English counts from 1 |
109
+ | `unused_variable` | info | a data variable that nothing mentions |
110
+ | `numeral_missing` | info | a number in the English that never appears in the Lean |
111
+
112
+ **Measured honestly** (`faithcheck bench data/misformal_bench_v0.jsonl`).
113
+ This counts how often each lint fires on the wrong statement versus the
114
+ fixed one, over 1,206 statement fixes:
115
+
116
+ | lint | fires on wrong | fires on fixed | rows where the fix removed it |
117
+ |---|---:|---:|---:|
118
+ | `optparam_binder` | 362 | 153 | 218 |
119
+ | `nat_fraction_exponent` | 5 | 1 | 4 |
120
+ | `nat_subtraction` | 58 | 45 | 17 |
121
+ | `int_division` | 20 | 17 | 6 |
122
+ | all lints | 517 | 302 | 248 |
123
+
124
+ On the `core` slice the static lints barely separate wrong from fixed. Most
125
+ real misformalizations are semantic, and pattern matching does not see them.
126
+ That is the point of the benchmark: it measures how far a checker is from
127
+ catching what humans had to fix. Beat these numbers.
128
+
129
+ On the current heads of the four source repositories, the static lints raise
130
+ only a handful of warnings. That is expected: these repositories have
131
+ already been cleaned by hand.
132
+
133
+ ### Bugs found so far
134
+
135
+ Four live misformalizations in miniF2F-lean4 (commit `5746b7d`), each with a
136
+ Lean proof that the statement is false or vacuous. The evidence is in
137
+ [`cases/evidence/`](cases/evidence/minif2f_nat_fraction_exponents.lean), and
138
+ the cases are in `cases/`:
139
+
140
+ | problem | what goes wrong | status |
141
+ |---|---|---|
142
+ | `mathd_algebra_208` | `1000000^(1/3)` is `1000000^0 = 1` | false |
143
+ | `mathd_algebra_275` | `11^(1/4) = 1`, so the hypothesis says `1 = 1/5` | vacuous |
144
+ | `amc12a_2020_p13` | all four `1/k` exponents are 0, so `h₂` says nothing | false |
145
+ | `mathd_algebra_282` | `8^(1/3) = 1`, so the sum is 78, not 79 | false |
146
+
147
+ The Lean vacuity check found `mathd_algebra_275`. The static lint written
148
+ from it then found the other three.
149
+
150
+ ### Lean-backed checks (experimental)
151
+
152
+ ```bash
153
+ faithcheck lean --project . --module MyProject.Problems MyProject/Problems.lean
154
+ ```
155
+
156
+ For each theorem `T`, this elaborates `example`s that ask generic automation
157
+ (`decide`, `simp_all`, `omega`, `linarith`, `aesop`, `plausible`) four
158
+ questions:
159
+
160
+ - Is `T` trivially true? If so, it is probably too weak.
161
+ - Do its hypotheses prove `False`? If so, it is vacuous.
162
+ - Does automation prove `¬T`? If so, it is false.
163
+ - Does `plausible` find a counterexample?
164
+
165
+ `trivial` is info-level: it is expected for pure computation problems. A
166
+ statement that does not elaborate (for example, because of a Mathlib version
167
+ mismatch) is reported once as `lean_source_error`, and no check is run on it.
168
+
169
+ **First full run (2026-12-05).** All 1,160 statements in miniF2F-lean4
170
+ (488) and PutnamBench (672) were checked on live.lean-lang.org (Lean
171
+ v4.37.0-rc2 with current Mathlib):
172
+
173
+ | | miniF2F | PutnamBench |
174
+ |---|---:|---:|
175
+ | checked | 488 | 671 (1 still pending when the run was read) |
176
+ | vacuous / refuted / counterexample | **1** (`mathd_algebra_275`, vacuous) | 0 |
177
+ | trivially provable | about 70, not yet reviewed (many are "compute this number" problems, where it is expected) | 0 that elaborate |
178
+ | did not elaborate on current Mathlib | 2 | at least 19 (version drift, not bugs) |
179
+ | timed out (120 s) | 2 | 2 |
180
+
181
+ ### GitHub Action
182
+
183
+ ```yaml
184
+ # .github/workflows/faithcheck.yml in your Lean repository
185
+ name: faithcheck
186
+ on: [pull_request]
187
+ jobs:
188
+ faithcheck:
189
+ runs-on: ubuntu-latest
190
+ steps:
191
+ - uses: actions/checkout@v4
192
+ - uses: aarcee17/misformal-bench@v0.1.1
193
+ with:
194
+ paths: MyProblems/
195
+ ```
196
+
197
+ The Action annotates the changed lines of a PR. It fails the job only if you set `strict: true`.
198
+
199
+ ## Contributing a misformalization
200
+
201
+ Found a Lean statement that does not say what its English says? Add it as a
202
+ case: see [CONTRIBUTING.md](CONTRIBUTING.md). Every accepted case becomes a
203
+ benchmark row with your name in `found_by`.
204
+
205
+ ## Rebuilding the dataset
206
+
207
+ ```bash
208
+ git clone https://github.com/google-deepmind/formal-conjectures
209
+ python scripts/mine_history.py formal-conjectures formal-conjectures raw/fc.jsonl FormalConjectures
210
+ # … the same for PutnamBench (lean4), compfiles (Compfiles), miniF2F-lean4 (MiniF2F)
211
+ python scripts/consolidate.py . 2026-07-01 raw/*.jsonl
212
+ ```
213
+
214
+ ## License
215
+
216
+ Code: Apache 2.0. Data: each row keeps its source repository's license; see [NOTICE](NOTICE).
@@ -0,0 +1,199 @@
1
+ # misformal-bench + faithcheck
2
+
3
+ **A Lean proof only certifies the Lean statement.** If the statement does not
4
+ say what the English problem says, a correct proof proves the wrong thing.
5
+ This repo is about that gap between English and Lean.
6
+
7
+ It has two parts:
8
+
9
+ - **misformal-bench**: 1,342 real misformalizations, mined from the fix
10
+ histories of four public Lean benchmarks. Each row is
11
+ *(English, wrong Lean statement, fixed Lean statement, commit)*.
12
+ - **faithcheck**: a pip-installable checker, plus a GitHub Action, that flags
13
+ Lean statements that may not match their English.
14
+
15
+ ## misformal-bench v0
16
+
17
+ | | rows | statement fixes | definition fixes | core statement fixes |
18
+ |---|---:|---:|---:|---:|
19
+ | formal-conjectures | 567 | 474 | 93 | 381 |
20
+ | PutnamBench | 717 | 687 | 30 | 177 |
21
+ | compfiles | 38 | 25 | 13 | 25 |
22
+ | miniF2F (Lean 4) | 20 | 20 | 0 | 20 |
23
+ | **total** | **1,342** | **1,206** | **136** | **603** |
24
+
25
+ Commits run from 2023-10-18 to 2026-06-29 (445 commits). Fixes committed
26
+ on or after 2026-07-01 are kept back as a private, held-out test set, so
27
+ scores on it cannot be inflated by training on it. `data/stats.json` has
28
+ the exact counts.
29
+
30
+ ### How rows are mined
31
+
32
+ `scripts/mine_history.py` walks each repository's history. It keeps a commit
33
+ when the commit message reads like a fix (fix, misformalization, correct,
34
+ wrong, typo, and similar) and is not about lint, build, imports, a toolchain
35
+ bump, renaming or style. For every theorem whose **statement** changed in
36
+ such a commit, it records the old and new statement. Comments and all
37
+ whitespace are ignored when comparing, so reformatting alone does not count.
38
+ Definition changes are tier `B_definition_fix`. Those rows list the theorems
39
+ that mention the definition in `dependents`.
40
+
41
+ ### Row fields
42
+
43
+ | field | meaning |
44
+ |---|---|
45
+ | `english` | docstring above the declaration (or the file's module docstring for compfiles) *before* the fix. Empty for PutnamBench, see below |
46
+ | `stmt_old`, `stmt_new` | signature (binders + type) before and after, comments stripped, whitespace normalised |
47
+ | `body_old`, `body_new` | for definition fixes only |
48
+ | `tier` | `A_statement_fix` or `B_definition_fix` |
49
+ | `core` | `false` for rows from commits that touch 10 or more declarations (mass migrations such as PutnamBench's optParam fix) and for pure `answer(sorry)` → `answer(True)` status updates |
50
+ | `doc_changed` | the English changed in the same commit. Sometimes the English was the thing that was wrong |
51
+ | `refixed_later` | the same declaration was fixed again later, so `stmt_new` is not final ground truth |
52
+ | `commit`, `commit_subject`, `commit_body`, `date`, `file`, `source` | provenance |
53
+ | `text_tags` | keyword tags from the commit message (slicing only, not labels) |
54
+
55
+ ### Known limits (read before using it for evaluation)
56
+
57
+ - **No row has been compiled.** These are statements as committed, against
58
+ whatever Mathlib each repository used at the time.
59
+ - **Precision is not 100%.** Some fix-labelled commits also carry refactors
60
+ or syntax changes. In a hand check of 30 random `core` statement rows
61
+ (seed 2026), 25 were clear semantic fixes, 3 were unclear (large rewrites)
62
+ and 2 were noise (`∈` → `in` syntax, a namespace qualifier). Treat `core`
63
+ rows as roughly 85–90% real fixes.
64
+ - **There is no positive (faithful) class.** Statements that stayed
65
+ unchanged for a long time are a reasonable source of negatives, but they
66
+ are not included.
67
+ - **PutnamBench English is not redistributed** (it is published with
68
+ permission from the MAA). Clone PutnamBench and run
69
+ `python scripts/fill_english.py data/misformal_bench_v0.jsonl /path/to/PutnamBench filled.jsonl`.
70
+ That fills 690 of 717 PutnamBench rows.
71
+
72
+ ## faithcheck
73
+
74
+ ```bash
75
+ pip install faithcheck # or: pip install -e . from this repo
76
+ faithcheck lint path/to/Project/ # static lints, no Lean needed
77
+ faithcheck lint --info --format github MyProblems/ # include smells, GitHub annotations
78
+ ```
79
+
80
+ ### Static lints (no Lean needed)
81
+
82
+ | lint | level | what it flags |
83
+ |---|---|---|
84
+ | `optparam_binder` | warning | `(x : T := v)` in a theorem. The theorem is still quantified over **every** `x`, so the default constrains nothing. This was PutnamBench's largest single bug class (218 statements fixed in one commit) |
85
+ | `sorry_in_statement` | warning | `sorry` inside the statement itself (`answer(sorry)` is allowed) |
86
+ | `nat_fraction_exponent` | warning | `x ^ (1 / 3)`: the exponent is a natural number, so `1 / 3 = 0` and the power is 1. Found by the Lean vacuity check on miniF2F (see below) |
87
+ | `nat_subtraction` | info | `a - b` on ℕ outside a cast, which truncates at 0 |
88
+ | `int_division` | info | `a / b` on ℕ/ℤ, which is floor division, and `x / 0 = 0` |
89
+ | `positivity_missing` | info | the English calls `n` a positive integer, `n : ℕ`, and nothing rules out `n = 0` |
90
+ | `type_mismatch` | info | the English says real numbers but the statement has only ℕ/ℤ, or the reverse |
91
+ | `range_from_zero` | info | `Finset.range n` (which is `{0, …, n-1}`) while the English counts from 1 |
92
+ | `unused_variable` | info | a data variable that nothing mentions |
93
+ | `numeral_missing` | info | a number in the English that never appears in the Lean |
94
+
95
+ **Measured honestly** (`faithcheck bench data/misformal_bench_v0.jsonl`).
96
+ This counts how often each lint fires on the wrong statement versus the
97
+ fixed one, over 1,206 statement fixes:
98
+
99
+ | lint | fires on wrong | fires on fixed | rows where the fix removed it |
100
+ |---|---:|---:|---:|
101
+ | `optparam_binder` | 362 | 153 | 218 |
102
+ | `nat_fraction_exponent` | 5 | 1 | 4 |
103
+ | `nat_subtraction` | 58 | 45 | 17 |
104
+ | `int_division` | 20 | 17 | 6 |
105
+ | all lints | 517 | 302 | 248 |
106
+
107
+ On the `core` slice the static lints barely separate wrong from fixed. Most
108
+ real misformalizations are semantic, and pattern matching does not see them.
109
+ That is the point of the benchmark: it measures how far a checker is from
110
+ catching what humans had to fix. Beat these numbers.
111
+
112
+ On the current heads of the four source repositories, the static lints raise
113
+ only a handful of warnings. That is expected: these repositories have
114
+ already been cleaned by hand.
115
+
116
+ ### Bugs found so far
117
+
118
+ Four live misformalizations in miniF2F-lean4 (commit `5746b7d`), each with a
119
+ Lean proof that the statement is false or vacuous. The evidence is in
120
+ [`cases/evidence/`](cases/evidence/minif2f_nat_fraction_exponents.lean), and
121
+ the cases are in `cases/`:
122
+
123
+ | problem | what goes wrong | status |
124
+ |---|---|---|
125
+ | `mathd_algebra_208` | `1000000^(1/3)` is `1000000^0 = 1` | false |
126
+ | `mathd_algebra_275` | `11^(1/4) = 1`, so the hypothesis says `1 = 1/5` | vacuous |
127
+ | `amc12a_2020_p13` | all four `1/k` exponents are 0, so `h₂` says nothing | false |
128
+ | `mathd_algebra_282` | `8^(1/3) = 1`, so the sum is 78, not 79 | false |
129
+
130
+ The Lean vacuity check found `mathd_algebra_275`. The static lint written
131
+ from it then found the other three.
132
+
133
+ ### Lean-backed checks (experimental)
134
+
135
+ ```bash
136
+ faithcheck lean --project . --module MyProject.Problems MyProject/Problems.lean
137
+ ```
138
+
139
+ For each theorem `T`, this elaborates `example`s that ask generic automation
140
+ (`decide`, `simp_all`, `omega`, `linarith`, `aesop`, `plausible`) four
141
+ questions:
142
+
143
+ - Is `T` trivially true? If so, it is probably too weak.
144
+ - Do its hypotheses prove `False`? If so, it is vacuous.
145
+ - Does automation prove `¬T`? If so, it is false.
146
+ - Does `plausible` find a counterexample?
147
+
148
+ `trivial` is info-level: it is expected for pure computation problems. A
149
+ statement that does not elaborate (for example, because of a Mathlib version
150
+ mismatch) is reported once as `lean_source_error`, and no check is run on it.
151
+
152
+ **First full run (2026-12-05).** All 1,160 statements in miniF2F-lean4
153
+ (488) and PutnamBench (672) were checked on live.lean-lang.org (Lean
154
+ v4.37.0-rc2 with current Mathlib):
155
+
156
+ | | miniF2F | PutnamBench |
157
+ |---|---:|---:|
158
+ | checked | 488 | 671 (1 still pending when the run was read) |
159
+ | vacuous / refuted / counterexample | **1** (`mathd_algebra_275`, vacuous) | 0 |
160
+ | trivially provable | about 70, not yet reviewed (many are "compute this number" problems, where it is expected) | 0 that elaborate |
161
+ | did not elaborate on current Mathlib | 2 | at least 19 (version drift, not bugs) |
162
+ | timed out (120 s) | 2 | 2 |
163
+
164
+ ### GitHub Action
165
+
166
+ ```yaml
167
+ # .github/workflows/faithcheck.yml in your Lean repository
168
+ name: faithcheck
169
+ on: [pull_request]
170
+ jobs:
171
+ faithcheck:
172
+ runs-on: ubuntu-latest
173
+ steps:
174
+ - uses: actions/checkout@v4
175
+ - uses: aarcee17/misformal-bench@v0.1.1
176
+ with:
177
+ paths: MyProblems/
178
+ ```
179
+
180
+ The Action annotates the changed lines of a PR. It fails the job only if you set `strict: true`.
181
+
182
+ ## Contributing a misformalization
183
+
184
+ Found a Lean statement that does not say what its English says? Add it as a
185
+ case: see [CONTRIBUTING.md](CONTRIBUTING.md). Every accepted case becomes a
186
+ benchmark row with your name in `found_by`.
187
+
188
+ ## Rebuilding the dataset
189
+
190
+ ```bash
191
+ git clone https://github.com/google-deepmind/formal-conjectures
192
+ python scripts/mine_history.py formal-conjectures formal-conjectures raw/fc.jsonl FormalConjectures
193
+ # … the same for PutnamBench (lean4), compfiles (Compfiles), miniF2F-lean4 (MiniF2F)
194
+ python scripts/consolidate.py . 2026-07-01 raw/*.jsonl
195
+ ```
196
+
197
+ ## License
198
+
199
+ Code: Apache 2.0. Data: each row keeps its source repository's license; see [NOTICE](NOTICE).
@@ -0,0 +1,2 @@
1
+ """faithcheck: flag Lean statements that may not say what their English says."""
2
+ __version__ = "0.1.1"
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())