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
[Merged by Bors] - feat(Data/Nat/Prime): add 2 theorems #11620
Conversation
Seems useful! Could you turn it into an iff lemma so that it can be used with |
Sure. I added 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lemmas and proofs seem fine to me. I believe it is worth asking an expert maintainer or someone who is familiar with simp
's inner workings, whether the iff
lemmas ought to be simp lemmas.
golf from @tb65536 Co-authored-by: Thomas Browning <tb65536@users.noreply.github.com>
67ff980
to
4b9eb09
Compare
Rebased |
No. |
I don't like the naming. Just adding a |
(Doesn't need |
Mathlib/Data/Nat/Prime.lean
Outdated
simp only [← or_iff_not_imp_left] | ||
exact h.eq_one_or_self_of_dvd | ||
|
||
theorem not_prime_of_dvd2 (h : ∃ m, m ∣ n ∧ 2 ≤ m ∧ m < n) : ¬Prime n := by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like 1 < m
is more natural than 2 ≤ m
(this would need to be changed on all the lemmas, including the original two).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like to hear other's opinion. When I wrote this, there's already theorem exists_dvd_of_not_prime2 {n : ℕ} (n2 : 2 ≤ n) (np : ¬Prime n) : ...
. I'm just mirroring existing code.
I updated the name to be |
Mathlib/Data/Nat/Prime.lean
Outdated
⟨exists_dvd_of_not_prime h, fun ⟨_,h1,h2,h3⟩ => not_prime_of_dvd_of_ne h1 h2 h3⟩ | ||
|
||
theorem exists_dvd_lt_iff_not_prime {n : ℕ} (h : 2 ≤ n) : (¬Prime n) ↔ ∃ m, m ∣ n ∧ 2 ≤ m ∧ m < n := | ||
⟨exists_dvd_of_not_prime2 h, fun ⟨_,h1,h2,h3⟩ => not_prime_of_dvd_of_lt h1 h2 h3⟩ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also rename exists_dvd_of_not_prime2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's something we ported from Mathlib3. I have no objection but I'm not sure if we should do this. @semorrison
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spaces are probably more consistent with overall style.
I also agree that the 2
in the name is not great.
style Co-authored-by: damiano <adomani@gmail.com>
style Co-authored-by: damiano <adomani@gmail.com>
Let's merge this as is. Change names of existing material can be done in another PR. bors merge |
Pull request successfully merged into master. Build succeeded: |
We have 2
exists_dvd_of_not_prime
, but not the other way round. I found these 2 theorems useful when proving a number is not a prime number.