norm_num
plugin for big operators #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This norm_num
plugin provides support for computing sums and products of
lists, multisets and finsets.
Example goals this plugin can solve:
∑ i in finset.range 10, (i^2 : ℕ) = 285
Π i in {1, 4, 9, 16}, nat.sqrt i = 24
([1, 2, 1, 3]).sum = 7
Implementation notes #
The tactic works by first converting the expression denoting the collection (list, multiset, finset) to a list of expressions denoting each element. For finsets, this involves erasing duplicate elements (the tactic fails if equality or disequality cannot be determined).
After rewriting the big operator to a product/sum of lists, we evaluate this
using norm_num
itself to handle multiplication/addition.
Finally, we package up the result using some congruence lemmas.
theorem
tactic.norm_num.list.sum_congr
{α : Type u_1}
[add_monoid α]
{xs xs' : list α}
{z : α}
(h₁ : xs = xs')
(h₂ : xs'.sum = z) :