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(Data/Fin/Parity): add lemmas about parity of Fin numbers #8960

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

Conversation

urkud
Copy link
Member

@urkud urkud commented Dec 10, 2023

Co-authored-by: Iván Renison [email protected]


Motivated by this Zulip question.

Open in Gitpod

@urkud urkud added awaiting-review t-algebra Algebra (groups, rings, fields, etc) t-order Order theory labels Dec 10, 2023
@urkud urkud added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review labels Dec 11, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) and removed blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) labels Dec 11, 2023
@leanprover-community-mathlib4-bot
Copy link
Collaborator

This PR/issue depends on:

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Dec 16, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Dec 20, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 8, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) and removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) labels May 25, 2024
@IvanRenison
Copy link
Collaborator

@urkud are you going to continue with this pull request? If not, can I continue with it?

@urkud
Copy link
Member Author

urkud commented Nov 1, 2024

Feel free to take over this PR. Thanks!

@github-actions github-actions bot added the t-data Data (lists, quotients, numbers, etc) label Nov 1, 2024
@IvanRenison IvanRenison changed the title feat(Fin/Parity): add Fin.even_iff feat(Data/Fin/Parity): add lemmas about parity of Fin numbers Nov 4, 2024
@IvanRenison IvanRenison removed the awaiting-author A reviewer has asked the author a question or requested changes label Nov 4, 2024
Copy link
Collaborator

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

maintainer merge

Copy link

github-actions bot commented Nov 6, 2024

🚀 Pull request has been placed on the maintainer queue by Ruben-VandeVelde.

@kim-em
Copy link
Contributor

kim-em commented Nov 6, 2024

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Nov 6, 2024
mathlib-bors bot pushed a commit that referenced this pull request Nov 6, 2024
@IvanRenison
Copy link
Collaborator

For some reason the commit has the "Co-authored-by" two times

@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Nov 6, 2024

Build failed:

@bryangingechen bryangingechen added awaiting-author A reviewer has asked the author a question or requested changes awaiting-CI and removed ready-to-merge This PR has been sent to bors. awaiting-author A reviewer has asked the author a question or requested changes labels Nov 7, 2024
@bryangingechen
Copy link
Contributor

bors d=IvanRenison

@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Nov 7, 2024

✌️ IvanRenison can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@bryangingechen
Copy link
Contributor

Please merge master, fix the breakage and then merge with bors d+ when done, thanks!

@@ -141,6 +141,18 @@ lemma two_mul_div_two_of_even : Even n → 2 * (n / 2) = n := fun h ↦
lemma div_two_mul_two_of_even : Even n → n / 2 * 2 = n :=
fun h ↦ Nat.div_mul_cancel ((even_iff_exists_two_nsmul _).1 h)

theorem one_lt_of_ne_zero_and_even {n : ℕ} (h0 : n ≠ 0) (hn : Even n) : 1 < 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.

According to the naming convention this should be one_lt_of_ne_zero_of_even.

rw [h] at hn
exact Nat.not_even_one hn

theorem add_one_lt_of_even_and_even_and_lt {n m : ℕ} (hn : Even n) (hm : Even m) (hnm : n < m) :
Copy link
Collaborator

Choose a reason for hiding this comment

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

According to the naming convention this should be add_one_lt_of_even_of_even_of_lt, but in any case that's quite long - I think add_one_lt_of_even is clear enough

@@ -430,6 +430,13 @@ theorem val_add_eq_ite {n : ℕ} (a b : Fin n) :
Nat.mod_eq_of_lt (show ↑b < n from b.2)]
--- Porting note: syntactically the same as the above

theorem val_add_eq_mod {n : ℕ} (a b : Fin n) : (a + b).val = (a.val + b.val) % n := rfl
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to be the same as Fin.val_add

@@ -430,6 +430,13 @@ theorem val_add_eq_ite {n : ℕ} (a b : Fin n) :
Nat.mod_eq_of_lt (show ↑b < n from b.2)]
--- Porting note: syntactically the same as the above

theorem val_add_eq_mod {n : ℕ} (a b : Fin n) : (a + b).val = (a.val + b.val) % n := rfl

theorem val_add_eq_of_sum_lt {n : ℕ} {a b : Fin n} (huv : a.val + b.val < n) :
Copy link
Collaborator

Choose a reason for hiding this comment

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

According to the naming convention this should be val_add_eq_of_add_lt - sum is for sums of sets/lists/etc.

@@ -451,6 +458,8 @@ whose value is the original number. -/
theorem val_cast_of_lt {n : ℕ} [NeZero n] {a : ℕ} (h : a < n) : (a : Fin n).val = a :=
Nat.mod_eq_of_lt h

theorem one_val_cast {n : ℕ} [NeZero n] (h : 1 < n) : (1 : Fin n).val = 1 := val_cast_of_lt h
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you need this for? Can't you use val_cast_of_lt directly, or val_cast_of_lt (a := 1)?

@Command-Master
Copy link
Collaborator

Apologies for the late review, I forgot to send it earlier

@Command-Master Command-Master added the awaiting-author A reviewer has asked the author a question or requested changes label Nov 7, 2024
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 awaiting-CI delegated maintainer-merge t-algebra Algebra (groups, rings, fields, etc) t-data Data (lists, quotients, numbers, etc) t-order Order theory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants