-
Notifications
You must be signed in to change notification settings - Fork 745
feat: lemmas about sums of lists/arrays/vectors #11994
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
|
Reference manual CI status:
|
|
Mathlib CI status (docs):
|
|
!radar |
|
Benchmark results for 75e46e1 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🟥)
|
| @[deprecated sum_toList (since := "2026-01-14")] | ||
| def sum_eq_sum_toList := @sum_toList | ||
|
|
||
| theorem sum_append [Zero α] [Add α] [Std.Associative (α := α) (· + ·)] |
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 it would be worthwhile to leave a comment here explaining why you haven't labelled these as simp, grind =, but only done this on the specializations.
In fact, even better would be to benchmark this against Mathlib, with and without annotations on the generic version. I suspect it is actually fine. (Perhaps not even that much work given our new infrastructure?)
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've annotated sum_append and sum_reverse instead now, I think the benchmark turned out neutral (as long as 0.5% on build//instructions and no other significant changes is natural variability...)
806f46d to
2c2226f
Compare
|
!bench mathlib |
|
Benchmark results for leanprover-community/mathlib4-nightly-testing@2975ae5 against leanprover-community/mathlib4-nightly-testing@e0bf30b are in! @datokrat
No significant changes detected. |
|
!bench mathlib |
|
Benchmark results for leanprover-community/mathlib4-nightly-testing@074ad7a against leanprover-community/mathlib4-nightly-testing@e0bf30b are in! @datokrat
No significant changes detected. |
3b3c846 to
b5cc59f
Compare
add lemmas used by HumanEval43 and HumanEval110 add required lemmas fix test cleanups improvements extract some changes into separate PR remove exists_mem_iff_... remove LeftIdentity instance parameter try marking sum_append and sum_reverse as simp/grind lemmas remove leftover annotations remove grind annotations on inequalities revert unrelated file revert more unrelated stuff
b3684b5 to
eccfc09
Compare
This PR provides more lemmas about sums of lists/arrays/vectors, especially sums of
NatorIntlists/arrays/vectors.This change has been motivated by my experience solving
human-eval-leanproblems. Sums, minima and maxima are frequently required and the improvements provided in this PR make it easier to verify such programming tasks.Changes:
sumequalsfoldl/foldr.sum_append_natandsum_reverse_natlemmas so that they are polymorphic, requiring only some type class instances about the list elements' type. The polymorphic lemmas aren't simp- or grind-annotated because I fear the instance synthesis overhead. However, theNatandIntspecializations are annotated (see below). Note that as{Array,Vector}.mindo not exist, some lemmas can't be stated and were omitted.List.min_singletonandList.max_singletonlemmas as they were needed for some proofs.Nat-related:{List,Array,Vector}.sumlemmas that are specific forNatinto their own module:Init.Data.List.Nat.Sum,Init.Data.Array.NatandInt.Data.Vector.Nat.Nat.sum_pos_iff_exists_posand renamed it toList.sum_pos_iff_exists_pos_nat. This is more consistent and made it possible to addArrayandVectorvariants of this lemma.l.sum / l.lengthlies between the minimum and the maximum of a list.Intlists/arrays/vectors to parallel modules:Init.Data.List.Int.Sum,Init.Data.Array.IntandInt.Data.Vector.Int.sum_eq_sum_toListtosum_toList, which better represents the theorem's content.