-
Notifications
You must be signed in to change notification settings - Fork 59
chore: golf proofs about merge #323
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: main
Are you sure you want to change the base?
Conversation
6184c03 to
7c3b828
Compare
7c3b828 to
225d57c
Compare
| · simp | ||
| · simp | ||
| · grind [cons_merge_cons] |
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 usually try to stay consistent about using simp or grind when they are both just working with theorems that make sense as @[simp, grind =] attributes, e.g.
| · simp | |
| · simp | |
| · grind [cons_merge_cons] | |
| · grind [nil_merge] | |
| · grind [merge_right] | |
| · grind [cons_merge_cons] |
(If these were already annotated upstream I'd just write fun_induction merge <;> grind, but I don't think it's helpful when you are specifying theorems for different branches manually.)
| | case3 => | ||
| grind | ||
| | _ => simp | ||
| simp |
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 you address the simpNF linter by removing ret_merge, this is the only affected proof that then becomes
| simp | |
| grind [List.length_merge] |
| | case2 _ _ _ _ _ ih2 ih1 => exact sorted_merge ih2 ih1 | ||
|
|
||
| lemma merge_perm (l₁ l₂ : List α) : ⟪merge l₁ l₂⟫ ~ l₁ ++ l₂ := by | ||
| fun_induction merge with |
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.
Seems like this should follow suit and be grind [List.merge_perm_append]
| /-- Key Lemma: ⌈log2 ⌈n/2⌉⌉ ≤ ⌈log2 n⌉ - 1 for n > 1 -/ | ||
| @[grind →] | ||
| lemma clog2_half_le (n : ℕ) (h : n > 1) : clog 2 ((n + 1) / 2) ≤ clog 2 n - 1 := by | ||
| rw [Nat.clog_of_one_lt one_lt_two 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.
If golfing, this could just be grind [Nat.clog_of_one_lt].
The lemmas this golfs are now unused, and could also be deleted.