-
Notifications
You must be signed in to change notification settings - Fork 335
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
base: master
Are you sure you want to change the base?
Conversation
This PR/issue depends on:
|
@urkud are you going to continue with this pull request? If not, can I continue with it? |
Feel free to take over this PR. Thanks! |
Fin.even_iff
Fin
numbers
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.
maintainer merge
🚀 Pull request has been placed on the maintainer queue by Ruben-VandeVelde. |
bors merge |
Co-authored-by: Iván Renison <[email protected]> Co-authored-by: Iván Renison <[email protected]>
For some reason the commit has the "Co-authored-by" two times |
Build failed: |
bors d=IvanRenison |
✌️ IvanRenison can now approve this pull request. To approve and merge a pull request, simply reply with |
Please merge |
@@ -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 |
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.
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) : |
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.
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 |
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.
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) : |
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.
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 |
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.
What do you need this for? Can't you use val_cast_of_lt
directly, or val_cast_of_lt (a := 1)
?
Apologies for the late review, I forgot to send it earlier |
Co-authored-by: Iván Renison [email protected]
Motivated by this Zulip question.