Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Archive/Imo): formalize IMO 1982q3 #16190

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

feat(Archive/Imo): formalize IMO 1982q3 #16190

wants to merge 19 commits into from

Conversation

AlexBrodbelt
Copy link
Collaborator

Formalized problem 3 of 1982 IMO.

For part a, helper lemmas like Sedrakayan's lemma, a specialization of the Cauchy-Schwarz inequality, and useful other inequalities involving summations to solve the main problem.

For part b, rearranging terms inside summations and involving summations in inequalities were proved.


Open in Gitpod

@github-actions github-actions bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label Aug 27, 2024
Copy link

github-actions bot commented Aug 27, 2024

PR summary c062503898

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ Ico_sdiff_zero_eq_Ico
+ Imo1982Q3_part_a
+ Imo1982Q3_part_b
+ Sedrakyan's_lemma
+ eq₀
+ ineq₁
+ ineq₂
+ ineq₃
+ sum_Fin_eq_sum_Ico

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Archive/Imo/Imo1982Q3.lean Outdated Show resolved Hide resolved
Archive/Imo/Imo1982Q3.lean Outdated Show resolved Hide resolved
AlexBrodbelt and others added 9 commits August 28, 2024 09:32
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines 210 to 211
lemma Ico_sdiff_zero_eq_Ico : ∀ N, Ico 0 N \ {0} = Ico 1 N := by
intro N
Copy link
Collaborator

Choose a reason for hiding this comment

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

General comments applicable both to this lemma and elsewhere in this PR:

  • Normally rather than having a lemma statement start with after the colon and then the proof starting with intro, we use named hypotheses before the colon, so (N : ℕ) in this case, and so don't need to start the proof with intro. Much the same applies if the statement is of the form h → p: move the hypotheses h before the colon rather than having an implication on the right hand side of the colon.
  • Standard indentation of the proof body is two columns, not four.

Specific remark about this lemma: it's essentially a combination of the existing lemmas sdiff_singleton_eq_erase, Ico_erase_left and Ico_succ_left. That should allow a much shorter proof. It might then be reasonable to inline that at the point where this lemma is needed.

AlexBrodbelt and others added 5 commits September 9, 2024 18:19
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@joneugster joneugster added the IMO Math olympiad problems label Sep 12, 2024
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines 68 to 72
have LHS_nonneg : 0 ≤ ∑ n : Fin n, √(y n) * (x n / √(y n)) := by
apply Finset.sum_nonneg
intro i _hi
apply mul_nonneg (le_of_lt (sqrt_yi_pos i))
apply div_nonneg (xi_nonneg _) (le_of_lt (sqrt_yi_pos _))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
have LHS_nonneg : 0 ≤ ∑ n : Fin n, √(y n) * (x n / √(y n)) := by
apply Finset.sum_nonneg
intro i _hi
apply mul_nonneg (le_of_lt (sqrt_yi_pos i))
apply div_nonneg (xi_nonneg _) (le_of_lt (sqrt_yi_pos _))
have LHS_nonneg : 0 ≤ ∑ n : Fin n, √(y n) * (x n / √(y n)) := by positivity

Comment on lines 43 to 48
/-
Specialization of Cauchy-Schwarz inequality with the sequences x n / √(y n) and √(y n)
-/
lemma Sedrakyan's_lemma {n : ℕ} {x y: EuclideanSpace ℝ (Fin n)}
(hN : 0 < n) (xi_pos : ∀ i, 0 < x i) (yi_pos : ∀ i, 0 < y i) :
(∑ n : Fin n, x n)^2 / (∑ n : Fin n, y n) ≤ (∑ n : Fin n, ((x n)^2 / (y n))) := by
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a general fact about sequences of reals. Can you generalise? The lemma you want to use is Finset.sum_mul_sq_le_sq_mul_sq instead of real_inner_le_norm

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd also like to reiterate my petition for this lemma to be added within Mathlib proper. It will definitely be useful for other IMO problems!

Copy link
Collaborator

Choose a reason for hiding this comment

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

have ne_zero' : (N : ℝ) - 10 := by
rw [ne_eq]; intro h
rw [sub_eq_iff_eq_add, zero_add] at h
rw [@Nat.cast_eq_one] at h
Copy link
Collaborator

Choose a reason for hiding this comment

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

These @ are usually useless

Suggested change
rw [@Nat.cast_eq_one] at h
rw [Nat.cast_eq_one] at h

@YaelDillies YaelDillies added the awaiting-author A reviewer has asked the author a question or requested changes label Sep 24, 2024
@hrmacbeth hrmacbeth self-assigned this Sep 24, 2024
@hrmacbeth
Copy link
Member

hrmacbeth commented Sep 24, 2024

@AlexBrodbelt, I have the impression that you have quite a few tricks yet to learn about writing analysis arguments in Lean. As an example, I have pushed an efficient proof of your first lemma.

The "Archive" is for high quality proofs that, while being mathematical "leaf theories", show off the automation and libraries developed in Mathlib. At the moment this proof is quite far from being this kind of showcase. If you want to work on getting this proof to that level, it will take a lot of back-and-forth, and this may proceed rather slowly, depending on reviewers' availability to point out inefficiencies.

If you just want to make this proof available in a public repository for the community to use, you might consider instead contributing it to https://github.com/dwrensha/compfiles. Are you aware of that project?

@vihdzp
Copy link
Collaborator

vihdzp commented Sep 24, 2024

I'm interested in helping clean this proof up! I just haven't found the time for it yet. Maybe sometime during the week?

One thing which I'd like to see beforehand (and I think I already mentioned this above) is Sedrakyan's lemma in a separate PR. There will almost definitely be more IMO problems that depend on this.

@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Oct 28, 2024
@dwrensha
Copy link
Member

FYI I added this solution to Compfiles: dwrensha/compfiles@e7f00a5

@vihdzp vihdzp self-assigned this Nov 22, 2024
@vihdzp
Copy link
Collaborator

vihdzp commented Nov 22, 2024

@AlexBrodbelt I did a complete rewrite of the proof on my own branch. It ends up being only about 100 lines long, and I think that it better showcases Mathlib's automation. If you think what I did is sensible, you can merge the changes in that branch with this branch. Note that my proof depends on PR #19311.

If you're not available to come back to this PR, I can take it over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author A reviewer has asked the author a question or requested changes IMO Math olympiad problems merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants