Skip to content

New Proofs Generated by Machines - #14

Open
yangky11 wants to merge 17 commits into
zhangir-azerbayev:mainfrom
yangky11:main
Open

yangky11 wants to merge 17 commits into
zhangir-azerbayev:mainfrom
yangky11:main

Conversation

@yangky11

@yangky11 yangky11 commented May 28, 2023 •

Copy link
Copy Markdown

Hi Zhangir,

We evaluated our machine learning prover on ProofNet and found some new proofs.

@zhangir-azerbayev

Copy link
Copy Markdown
Owner

One thing I am concerned about is that including proofs in this Github repo will result in lots of models being trained on them. Would it be possible to instead add these machine proofs as an extra column to the huggingface dataset and add a line in this repo's README pointing to huggingface?

I already regret hosting any part of this benchmark on Github, but at least the formal proofs can be saved from data contamination.

@alreadydone alreadydone 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.

It turns out many of the "solutions" are due to erroneous formalization.

Personally, I'd like to see techniques like reflection, self-consistency, and refinement/debate/critique etc. be used together with autoformalization to automatically catch dubious formalizations and generate reasoning traces / CoT (ToT?) data that could be used to fine-tune the model.

It does not seem outlandish to hope LLMs could become sample efficient enough to master a subject just by reading a book on it, doing all exercises, and fine-tuning on all thoughts generated in the process. It seems people are having success building customer service bots etc. by embedding and retrieving from documentation and historical Q&A data and prompting with retrieved entries, without the need of fine-tuning; nowadays there are even long context models like MPT-65k and Claude-100k that can fit a whole book into their working memory. However, for hard tasks like mathematics, I think fine-tuning on synthetic reasoning data would definitely be beneficial, given unsatisfactory reasoning capabilities of current (especially open source) models.

Comment on lines 18 to +22
theorem exercise_2_1_26 {G : Type*} [group G]
[fintype G] (a : G) : ∃ (n : ℕ), a ^ n = 1 :=
sorry
begin
exact ⟨0, pow_zero a⟩,
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The exercise states "positive integer".

Comment on lines 362 to 363
theorem exercise_7_1_12 {F : Type*} [field F] {K : subring F}
(hK : (1 : F) ∈ K) : is_domain K :=

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

hK is redundant by definition of subring in mathlib (see subring.one_mem).


theorem exercise_4_5_17 {G : Type*} [fintype G] [group G]
(hG : card G = 105) :
nonempty(sylow 5 G) ∧ nonempty(sylow 7 G) :=

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Both exercises require the Sylow subgroups to be normal, which is omitted in both formalizations.

Comment on lines 157 to 159
theorem exercise_3_1_22b {G : Type*} [group G] (I : Type*)
(H : I → subgroup G) (hH : ∀ i : I, subgroup.normal (H i)) :
subgroup.normal (⨅ (i : I), H i):=

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should probably be added to mathlib ...

[module F V] (v : V) (a : F): a • v = 0 ↔ a = 0 ∨ v = 0 :=
sorry
begin
simp [smul_eq_mul],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

smul_eq_mul isn't actually used, I guess.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yep, smul_eq_mul is indeed redundant here, but that's what the prover generated.

Comment thread benchmark/benchmark_to_publish/formal/Artin.lean Outdated
Comment on lines 24 to 25
theorem exercise_2_1_27 {G : Type*} [group G]
[fintype G] : ∃ (m : ℕ), ∀ (a : G), a ^ m = 1 :=

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This exercise states "integer m > 0" too, but fintype.card G does satisfy the condition.

Comment thread benchmark/benchmark_to_publish/formal/Herstein.lean Outdated
Comment on lines +11 to +18
theorem exercise_2018_a5 (f : ℝ → ℝ) (hf : cont_diff ℝ ⊤ f)
(hf0 : f 0 = 0) (hf1 : f 1 = 1) (hf2 : ∀ x, f x ≥ 0) :
∃ (n : ℕ) (x : ℝ), iterated_deriv n f x = 0 :=
sorry
begin
use (1/2),
use 0,
norm_num [hf0],
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How could there be such an easy Putnam problem? Turns out the statement should say iterated_deriv n f x < 0, see https://kskedlaya.org/putnam-archive/2018.pdf

Comment thread benchmark/benchmark_to_publish/formal/Putnam.lean Outdated
Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>
Comment thread benchmark/benchmark_to_publish/formal/Herstein.lean Outdated
Comment thread benchmark/benchmark_to_publish/formal/Dummit-Foote.lean Outdated
@zhangir-azerbayev

Copy link
Copy Markdown
Owner

Thank you for the corrections @alreadydone ! I've added commits that fix 6 wrong formalization and improve two formalizations.

@yangky11 It would be great if you could rerun your model on the statements that were modified.

I still would like to avoid having solutions to the benchmark on Github. I still would suggest adding a reference_formal_proof column to the huggingface dataset.

@zhangir-azerbayev zhangir-azerbayev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

  1. Rerun model on modified statements.
  2. Delete solutions from Github and move to huggingface.

@yangky11

yangky11 commented May 31, 2023 •

Copy link
Copy Markdown
Author

Hi Zhangir and Junyan,

Thank you for your feedback on these proofs! That's really helpful, because, TBH, I cannot make sense of most of these theorems/proofs. I agree with Zhangir's worry about data contamination and potentially moving all proofs to another place. Do we know Hugging Face is not included in the training data of LLMs? Also, if all proofs are removed from the repo, we need a convenient way to track which theorems have proofs (maybe using comments next to sorry?). In any case, I just wanted to share the proofs, and it's totally up to you what you want to do with them.

It's quite surprising to me many of these proofs uncover issues of the original formalization. Now I'm a bit short of compute due to an incoming deadline, but I'm happy to run the prover on the updated proofs later.

@yangky11 yangky11 changed the title 26 New Proofs Generated by Machines New Proofs Generated by Machines Jun 8, 2023
@yangky11

yangky11 commented Jun 8, 2023 •

Copy link
Copy Markdown
Author

Hi,

I have finished re-running a new version of the model. It proved 1 out of the 7 modified theorems (f63ea51). In addition, it also proved 10 theorems that weren't in the first batch (5854981, 19b1112). @alreadydone It would be great if you can take a look and see if any of them has incorrect theorem statement. Thank you!

@alreadydone

Copy link
Copy Markdown

Thanks! There are some nice proofs, but I also spotted some problems in formalization, which @zhangir-azerbayev can take a look at 19b1112. I also find strange numberings inconsistent with Pugh's book, see 060d4b1#r117194793

@eric-wieser

Copy link
Copy Markdown
Contributor

I already regret hosting any part of this benchmark on Github

Can you elaborate on why?

@BartoszPiotrowski

Copy link
Copy Markdown
Collaborator

I already regret hosting any part of this benchmark on Github

Can you elaborate on why?

Zhangir may elaborate more, but the issue simply is that the benchmark is meant for evaluating LLMs, and because they are typically pretrained on multiple internet resources -- including Github -- it means that these models may memorize the examples from the benchmark. Then good performance achieved on the tasks based on the benchmark cannot be fully attributed to generalization achieved by the model but at least partially to memorization.

@zhangir-azerbayev

Copy link
Copy Markdown
Owner

Thanks @yangky11 for the proofs and @alreadydone for catching errors. Here's my plan for how to proceed with this PR.

  1. Fix all the remaining incorrect formalizations identified by @alreadydone
  2. Delete machine-generated solutions from this PR. Instead, I will add a new dict-valued column to the huggingface dataset titled "machine-solutions", whose values will have scheme {system-name: formal-proof}. This way we can keep track of machine solutions from multiple models without risk training set contamination (I expect people will have the good sense to not download huggingface when training their models).

@yangky11

yangky11 commented Jun 9, 2023 •

Copy link
Copy Markdown
Author

@alreadydone Thank you for checking the proofs! @zhangir-azerbayev That sounds good to me! It would also be great to keep track of which theorems have proofs in the comments in this repo.

Our system name is ReProver. We're wrapping up the project and will release the paper and code soon.

@alreadydone alreadydone 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.

In response to an email from @yangky11 I'm adding more comments.

Comment on lines 103 to +108
theorem exercise_11_2_13 (a b : ℤ) :
(of_int a : gaussian_int) ∣ of_int b → a ∣ b :=
sorry
begin
contrapose,
simp,
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

squeeze_simp gives simp only [of_int_eq_coe, coe_int_dvd_coe_int, imp_self] but exact (coe_int_dvd_coe_int a b).1 is sufficient.

Comment on lines +151 to +152
rintros ⟨a⟩ ⟨b⟩,
exact congr_arg coe (mul_comm a b)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

exact mul_comm works.

Comment on lines +166 to +175
rw infi,
rw ←set.image_univ,
rw Inf_image,
simp [hH],
haveI := λ i, (H i).normal,
split,
intros x hx g,
rw subgroup.mem_infi at hx ⊢,
intro i,
apply (hH i).conj_mem _ (hx i),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We can produce a shorter proof manually, but it's certainly nice to be able to automate this.

Suggested change
rw infi,
rw ←set.image_univ,
rw Inf_image,
simp [hH],
haveI := λ i, (H i).normal,
split,
intros x hx g,
rw subgroup.mem_infi at hx ⊢,
intro i,
apply (hH i).conj_mem _ (hx i),
split,
simp_rw subgroup.mem_infi,
exact λ x hx g i, (hH i).conj_mem _ (hx i) _,

Comment on lines +356 to +357
cases sq_eq_one_iff.1 hx with h h,
exacts [or.inl h, or.inr h],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
cases sq_eq_one_iff.1 hx with h h,
exacts [or.inl h, or.inr h],
exact sq_eq_one_iff.1 hx

is_open_map π₁ ∧ is_open_map π₂ :=
sorry
begin
simp [is_open_map_iff_nhds_le, h₁, h₂],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

An occasion where appropriate lemmas aren't used but rather the proof is adapted; the following proof, albeit longer, would be preferred in mathlib for performance reasons.

Suggested change
simp [is_open_map_iff_nhds_le, h₁, h₂],
rw [h₁, h₂], exact ⟨is_open_map_fst, is_open_map_snd⟩,

Comment on lines +119 to +122
rw set.diff_eq,
use hU.inter hA.is_open_compl,
rw set.diff_eq,
exact hA.inter hU.is_closed_compl,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Again, lemma not used but proof got adapted:

Suggested change
rw set.diff_eq,
use hU.inter hA.is_open_compl,
rw set.diff_eq,
exact hA.inter hU.is_closed_compl,
exact ⟨hU.sdiff hA, hA.sdiff hU⟩

continuous (λ x, min (f x) (g x)) :=
sorry
begin
simpa only [min_def] using hf.min hg,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The simp only part may have been copied from https://github.com/leanprover-community/mathlib/blob/bf9bbbcf0c1c1ead18280b0d010e417b10abb1b6/src/topology/order/basic.lean#L562

Suggested change
simpa only [min_def] using hf.min hg,
exact hf.min hg

Comment on lines +18 to +20
rw is_open_iff_nhds,
simp [cluster_pt],
simp [filter.inf_principal_eq_bot],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It took me several minutes to come up with the proof

Suggested change
rw is_open_iff_nhds,
simp [cluster_pt],
simp [filter.inf_principal_eq_bot],
simp_rw [is_open_iff_eventually, cluster_pt_principal_iff_frequently, not_frequently, not_mem_compl_iff],

so it's great that it can be automated. This proof can be condensed to

Suggested change
rw is_open_iff_nhds,
simp [cluster_pt],
simp [filter.inf_principal_eq_bot],
simp [is_open_iff_nhds, cluster_pt, filter.inf_principal_eq_bot],

to avoid a non-terminal simp.

Comment on lines +121 to +122
rw [norm_add_sq_real, norm_sub_pow_two_real],
ring,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This proof could directly use parallelogram_law_with_norm rather than "re-proving" it, but that requires specifying an implicit argument with @. I wonder whether the model tried to use it initially but failed. It's nice that it figured out it could use lemmas that specialize to real inner product spaces.

Suggested change
rw [norm_add_sq_real, norm_sub_pow_two_real],
ring,
simp_rw [sq, @parallelogram_law_with_norm ℝ, mul_add],

Comment on lines +46 to +49
cases eq_or_ne x 1,
all_goals { simp [h] },
apply order_of_eq_prime,
exacts [hx, h],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This proof is interesting as it takes a different approach than I would.

Suggested change
cases eq_or_ne x 1,
all_goals { simp [h] },
apply order_of_eq_prime,
exacts [hx, h],
exact (dvd_prime $ by norm_num).1 (order_of_dvd_of_pow_eq_one hx),

@alreadydone

alreadydone commented Jul 14, 2023 •

Copy link
Copy Markdown

Personally, I'd like to see techniques like reflection, self-consistency, and refinement/debate/critique etc. be used together with autoformalization to automatically catch dubious formalizations and generate reasoning traces / CoT (ToT?) data that could be used to fine-tune the model.

Some Amazon guys did self-consistency for autoformalization: https://twitter.com/johnjnay/status/1679687620228530177 (Isabelle MiniF2F, not Lean though).

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.

5 participants