-
Notifications
You must be signed in to change notification settings - Fork 630
feat(Data/Nat/Fib/Basic): some API for Nat.fib
#26962
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
base: master
Are you sure you want to change the base?
Conversation
PR summary 1ec99bd9a0Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
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.
These results all seem kind of fishy to me; natural number subtraction is usually something to be avoided. Nevertheless, some comments.
· exact le_refl _ | ||
· exact le_trans hd fib_le_fib_succ | ||
|
||
lemma fib_succ_sub_fib_pred {n : ℕ} (hn : n ≠ 0) : |
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 think using sub_eq_iff_eq_add'
(if imports permit) might give you a slightly shorter proof, since you avoid the add_comm
.
Are you sure you need these theorems, though? Natural number subtraction is very different from subtraction on the integers; it's likely not what you want.
Mathlib/Data/Nat/Fib/Basic.lean
Outdated
nth_rw 3 [fib_sub_one hn] | ||
simp [Nat.mul_sub] | ||
rw [← Nat.sub_add_eq, tsub_add_tsub_comm | ||
(Nat.mul_le_mul (le_refl _) (fib_le_fib_of_le (by omega))) |
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 think you can golf this proof slightly by using mul_left_mono
.
@@ -150,6 +164,21 @@ theorem fib_add (m n : ℕ) : fib (m + n + 1) = fib m * fib n + fib (m + 1) * fi | |||
simp only [fib_add_two, ih] | |||
ring | |||
|
|||
lemma fib_add_ne_zero {m n : ℕ} (hn : n ≠ 0) : |
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 don't know if I see the point of having this alongside fib_add
.
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 it's convenient to have this alongside fib_add
@@ -150,6 +159,21 @@ theorem fib_add (m n : ℕ) : fib (m + n + 1) = fib m * fib n + fib (m + 1) * fi | |||
simp only [fib_add_two, ih] | |||
ring | |||
|
|||
lemma fib_add_ne_zero {m n : ℕ} (hn : n ≠ 0) : |
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.
If this is kept, it should be:
lemma fib_add_ne_zero {m n : ℕ} (hn : n ≠ 0) : | |
lemma fib_add_of_ne_zero {m n : ℕ} (hn : n ≠ 0) : |
Added some helpful lemmas for
Nat.fib
.