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 1964 problem 1 #4369

Closed
wants to merge 4 commits into from
Closed

Conversation

knaka3435
Copy link
Collaborator

@knaka3435 knaka3435 commented Oct 2, 2020

The problem states:
(a) Find all positive n such that 2^n-1 is divisible by 7
(b) Prove that for all positive n, 2^n+1 is not divisible by 7

It might be more desirable to have it be in a more literal formalization of the problem statements, however, coercions seem painful to get to zmod.
Also features a nice simp lemma, thanks to @jcommelin (as well as main fact) as discussed here.

@knaka3435 knaka3435 added the awaiting-review The author would like community review of the PR label Oct 2, 2020
archive/imo/imo1964_q1.lean Outdated Show resolved Hide resolved
* (a) Find all positive integers `n` for which `2^n-1` is divisble by `7`.
* (b) Prove that there is no positive integer `n` for which `2^n+1` is divisible by `7`.
-/
example (n : ℕ) (gt_zero : 0 < n) : ((2^n -1) : zmod 7) = 0 ↔ (n : zmod 3) = 0 :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not exactly sure what our principles are for formalizing statements like this, but I think we could phrase this a smidge more literally, without causing any serious problems.

Would this be difficult?

Suggested change
example (n : ) (gt_zero : 0 < n) : ((2^n -1) : zmod 7) = 0 ↔ (n : zmod 3) = 0 :=
example (n : ) (gt_zero : 0 < n) : 7 | (2^n -1) 3 | n :=

Copy link
Collaborator Author

@knaka3435 knaka3435 Oct 3, 2020

Choose a reason for hiding this comment

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

For the other proof it seems to be no problem to change this directly, but for this one, I've ran into (\u(2^n-1 : nat) : zmod 7) = 2^n-1 which is giving me some problems.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For questions of the form "Find all numbers for which blah", I've been formalizing it as, first write a problem_predicate which is what the problem is giving, then write a solution_predicate for what you claim the solution is, in some sort of simple form, and then the main theorem is that the two are equal. If it's a pain to muck around with converting between modular arithmetic and regularly arithmetic, well basically yeah, that's one of the main difficulties with formalizing things. For any sort of IMO challenge we won't get the problems in the most convenient form, so it's better to describe the problem in the way most similar to the problem statement.

norm_num }
end

example (n : ℕ) (gt_zero : 0 < n) : ¬((2^n + 1) : zmod 7) = 0 :=
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
example (n : ) (gt_zero : 0 < n) : ¬((2^n + 1) : zmod 7) = 0 :=
example (n : ) (gt_zero : 0 < n) : ¬ (7 | 2^n + 1) :=

@awainverse awainverse added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Oct 3, 2020
haveI : fact (nat.prime 7) := by { delta fact, norm_num },
have h2 : (2 % 7) ≠ 0 := dec_trivial,
rw ← nat.mod_add_div n 6,
have : 6 * (n / 6) % 3 = 0, sorry,
Copy link
Member

Choose a reason for hiding this comment

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

Do you need help with these sorrys? Or are you working on them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm working on them, since the past few days have been rather busy.

@fpvandoorn fpvandoorn added the WIP Work in progress label Oct 6, 2020
@jcommelin jcommelin added the imo Formalisation of an IMO problem label Oct 8, 2020
@knaka3435 knaka3435 closed this Nov 7, 2020
bors bot pushed a commit that referenced this pull request Nov 12, 2020
This is an alternative approach to #4369, where progress seems to have stalled. I avoid integers completely by working with `nat.modeq`, and deal with the cases of n mod 3 by simply breaking into three cases.



Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
@YaelDillies YaelDillies deleted the 1964_imo_1 branch October 19, 2021 20:25
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 Formalisation of an IMO problem WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants