Skip to content

Archive: a^n+1 is prime only if n is a power of two#14049

Closed
rwst wants to merge 0 commit intomasterfrom
rwst/archive01
Closed

Archive: a^n+1 is prime only if n is a power of two#14049
rwst wants to merge 0 commit intomasterfrom
rwst/archive01

Conversation

@rwst
Copy link
Copy Markdown
Collaborator

@rwst rwst commented Jun 23, 2024

The fact that primes of the form a^n+1 must have n a power of two was stated and
the proof outlined in three sentences by Euler in the year 1738 [E026]. A proof can be
found in Hardy & Wright, An introduction to the theory of numbers (5th ed., 1979),
p.15, Theorem 17. In the proof below we followed Euler's thoughts.


Open in Gitpod

@rwst rwst added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. t-number-theory Number theory (also use t-algebra or t-analysis to specialize) labels Jun 23, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 23, 2024

PR summary 6f097b9016

Import changes

No significant changes to the import graph


Declarations diff

+ pow_of_pow_add_prime

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

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

@rwst
Copy link
Copy Markdown
Collaborator Author

rwst commented Jun 23, 2024

Unclear what and why is failing...

@Rida-Hamadani
Copy link
Copy Markdown
Collaborator

Run lake exe mk_all in terminal then push again. This is required when you create a new file.

@rwst
Copy link
Copy Markdown
Collaborator Author

rwst commented Jun 23, 2024

@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Jun 23, 2024
Copy link
Copy Markdown
Contributor

@Ruben-VandeVelde Ruben-VandeVelde left a comment

Choose a reason for hiding this comment

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

Thanks, some mostly stylistic suggestions.

Should this go into archive or mathlib proper?

Comment on lines +120 to +121
have true_or_false (A B : Prop) (hB : ¬ B) (hab : A ∨ B) : A := by simp_all only [or_false]
apply true_or_false at h₁
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You may be looking for Or.resolve_right

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This changes the logic, so I'd rather leave it. Is it a problem?

@Ruben-VandeVelde Ruben-VandeVelde added awaiting-author A reviewer has asked the author a question or requested changes. and removed awaiting-review labels Jun 24, 2024
@rwst
Copy link
Copy Markdown
Collaborator Author

rwst commented Jun 25, 2024

Should this go into archive or mathlib proper?

Thank for the review. I think some proof of this should go in Mathlib, but not sure about this one. Other proofs can be found or are linked in https://math.stackexchange.com/questions/140804/if-2n1-is-prime-why-must-n-be-a-power-of-2, and there is the one in Harvey & Wright mentioned in this PR. I do not know if these are shorter / more elegant.

@rwst rwst added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. and removed awaiting-author A reviewer has asked the author a question or requested changes. awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. labels Jun 25, 2024
@tb65536
Copy link
Copy Markdown
Contributor

tb65536 commented Jun 25, 2024

I would be in favor of this result going into mathlib with a more streamlined proof.

@rwst
Copy link
Copy Markdown
Collaborator Author

rwst commented Jun 25, 2024

I would be in favor of this result going into mathlib with a more streamlined proof.

Do you think this specific approach can be substantially streamlined? Or do you think another approach would result in what could go in Mathlib? I might take this up then, but it wouldn't affect this PR, I guess.

@rwst
Copy link
Copy Markdown
Collaborator Author

rwst commented Jun 25, 2024

I would be in favor of this result going into mathlib with a more streamlined proof.

Maybe I misunderstood. Did you mean mathlib or mathlib/Mathlib?

@tb65536
Copy link
Copy Markdown
Contributor

tb65536 commented Jun 25, 2024

I meant mathlib/Mathlib. I think a more direct approach would probably be better. Perhaps something along the lines of this:

theorem Nat.exists_eq_two_pow_mul_odd {n : ℕ} (hn : n ≠ 0) : ∃ k m : ℕ, Odd m ∧ n = 2 ^ k * m :=
  let ⟨k, m, hm, hn⟩ := Nat.exists_eq_pow_mul_and_not_dvd hn 2 (Nat.succ_ne_self 1)
  ⟨k, m, Nat.odd_iff_not_even.mpr (mt Even.two_dvd hm), hn⟩

theorem Odd.nat_add_one_dvd_pow_add_one (x : ℕ) {n : ℕ} (hn : Odd n) : x + 1 ∣ x ^ n + 1 := by
  simpa only [one_pow] using hn.nat_add_dvd_pow_add_pow x 1

theorem H3 (a n : ℕ) (ha : 1 < a) (hn : 1 < n) (hP : Nat.Prime (a ^ n + 1)) :
    ∃ m : ℕ, n = 2 ^ m := by
  obtain ⟨k, m, hm, rfl⟩ := Nat.exists_eq_two_pow_mul_odd (one_pos.trans hn).ne'
  have key := hm.nat_add_one_dvd_pow_add_one (a ^ 2 ^ k)
  rw [pow_mul] at hP
  sorry

@rwst rwst added WIP Work in progress and removed awaiting-review labels Jun 26, 2024
. use a ^ 2 ^ k + 1
have h₁ : a ^ 2 ^ k + 1 ≠ 1 := by
rw [ne_eq, add_left_eq_self, pow_eq_zero_iff]
. exact not_eq_zero_of_lt ha
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style] reported by reviewdog 🐶

Suggested change
. exact not_eq_zero_of_lt ha
· exact not_eq_zero_of_lt ha

@rwst
Copy link
Copy Markdown
Collaborator Author

rwst commented Jun 26, 2024

Remarkable reduction, many thanks. I used this, and you can see the result in the last commit, which I hope is not too bad. I think this commit (after I have reduced it further) will then be split into several PRs because the lemmas belong to different parts of Mathlib. This PR will depend on them and the code will move to Nat.Prime. All with attribution. That's my idea. What do you think?

mathlib-bors bot pushed a commit that referenced this pull request Jun 27, 2024
Any nonzero natural number is the product of an odd part `m` and a power of two `2 ^ k`.

This is a trivial consequence of the existing `exists_eq_pow_mul_and_not_dvd`, but performs a convenient restatement in terms of `Odd`.

Needed by #14049.

Co-authored-by: Thomas Browning <tb65536@uw.edu>
@rwst
Copy link
Copy Markdown
Collaborator Author

rwst commented Jun 27, 2024

@tb65536 where to put the final theorem? I looked at Data.Nat.Prime but adding the import of Data.Nat.Factorization.Basic (because of #14166) creates a circular dependency. We also need to import Algebra.GeomSum (#14180) and Data.Nat.Defs (#14183). These are all short so their body could just be copied without importing them. I might just do that.

No, copying won't work because of Nat.exists_eq_pow_mul_and_not_dvd which would also be needed from Factorization.Basic. So, Data.Nat.Prime is not the right place. I also think Data.Nat.Prime is too fat and should be split.

mathlib-bors bot pushed a commit that referenced this pull request Jun 29, 2024
For `a > 1`, `a ^ b = a` iff `b = 1`. Lemma needed by #14049.

Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 2, 2024
dagurtomas pushed a commit that referenced this pull request Jul 2, 2024
Any nonzero natural number is the product of an odd part `m` and a power of two `2 ^ k`.

This is a trivial consequence of the existing `exists_eq_pow_mul_and_not_dvd`, but performs a convenient restatement in terms of `Odd`.

Needed by #14049.

Co-authored-by: Thomas Browning <tb65536@uw.edu>
dagurtomas pushed a commit that referenced this pull request Jul 2, 2024
For `a > 1`, `a ^ b = a` iff `b = 1`. Lemma needed by #14049.

Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>
@ghost ghost added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jul 2, 2024
@ghost ghost removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jul 3, 2024
@ghost
Copy link
Copy Markdown

ghost commented Jul 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) t-number-theory Number theory (also use t-algebra or t-analysis to specialize) WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants