-
Notifications
You must be signed in to change notification settings - Fork 734
feat: various small list/array/vector API improvements #12017
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
|
!radar |
|
Benchmark results for 36bde59 against e56351d are in! @datokrat Warnings (2)These warnings may indicate that the benchmark results are not directly comparable, for example due to changes in the runner configuration or hardware.
Small changes (2✅, 10🟥)
|
|
Reference manual CI status:
|
|
Mathlib CI status (docs):
|
de215c5 to
d2e88bf
Compare
| @[grind ←=] | ||
| theorem Grind.countP_eq_zero_of_forall {xs : Array α} (h : ∀ x ∈ xs, ¬ p x) : xs.countP p = 0 := | ||
| countP_eq_zero.mpr h | ||
|
|
||
| /-- This lemma is only relevant for `grind`. -/ | ||
| theorem Grind.not_of_countP_eq_zero_of_mem {xs : Array α} (h : xs.countP p = 0) (h' : x ∈ xs) : ¬ p x := | ||
| countP_eq_zero.mp h _ h' | ||
|
|
||
| grind_pattern Grind.not_of_countP_eq_zero_of_mem => xs.countP p, x ∈ xs where | ||
| guard xs.countP p = 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'm not really happy with this approach of grindifying countP_eq_zero, but I couldn't come up with something better. I tend to think that these grind lemmas are useful, but am not 100% sure that adding them is worth it.
This PR makes several small improvements to the list/array/vector API:
Init.Core.List.isSome_min_iffandList.isSome_max_iff.grindandsimpannotations to various previously unannotated lemmas.∃ x ∈ xs, P xusing indices as∃ (i : Nat), ∃ hi, P (xs[i]), and similar universally quantified lemmas:exists_mem_iff_exists_getElemandforall_mem_iff_forall_getElem.Vector.toList_zip.map_ofFnandofFn_getElemfor lists/arrays/vectors.