Big operators #
In this file we define products and sums indexed by finite sets (specifically, Finset
).
Notation #
We introduce the following notation, localized in BigOperators
.
To enable the notation, use open BigOperators
.
Let s
be a Finset α
, and f : α → β
a function.
∏ x in s, f x
is notation forFinset.prod s f
(assumingβ
is aCommMonoid
)∑ x in s, f x
is notation forFinset.sum s f
(assumingβ
is anAddCommMonoid
)∏ x, f x
is notation forFinset.prod Finset.univ f
(assumingα
is aFintype
andβ
is aCommMonoid
)∑ x, f x
is notation forFinset.sum Finset.univ f
(assumingα
is aFintype
andβ
is anAddCommMonoid
)
Implementation Notes #
The first arguments in all definitions and lemmas is the codomain of the function of the big
operator. This is necessary for the heuristic in @[to_additive]
.
See the documentation of to_additive.attr
for more information.
∑ x in s, f x
is the sum of f x
as x
ranges over the elements
of the finite set s
.
Equations
- Finset.sum s f = Multiset.sum (Multiset.map f s.val)
Instances For
∏ x in s, f x
is the product of f x
as x
ranges over the elements of the finite set s
.
Equations
- Finset.prod s f = Multiset.prod (Multiset.map f s.val)
Instances For
∑ x, f x
is notation for Finset.sum Finset.univ f
. It is the sum of f x
,
where x
ranges over the finite domain of f
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
∏ x, f x
is notation for Finset.prod Finset.univ f
. It is the product of f x
,
where x
ranges over the finite domain of f
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
∑ x in s, f x
is notation for Finset.sum s f
. It is the sum of f x
,
where x
ranges over the finite set s
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
∏ x in s, f x
is notation for Finset.prod s f
. It is the product of f x
,
where x
ranges over the finite set s
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Delaborator for Finset.prod
. The pp.piBinderTypes
option controls whether
to show the domain type when the product is over Finset.univ
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Delaborator for Finset.prod
. The pp.piBinderTypes
option controls whether
to show the domain type when the sum is over Finset.univ
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Deprecated: use _root_.map_sum
instead.
Deprecated: use _root_.map_prod
instead.
Deprecated: use _root_.map_sum
instead.
Deprecated: use _root_.map_prod
instead.
A morphism into the opposite ring acts on the product by acting on the reversed elements.
The sum of f
over insert a s
is the same as
the sum over s
, as long as a
is in s
or f a = 0
.
The product of f
over insert a s
is the same as
the product over s
, as long as a
is in s
or f a = 1
.
The sum of f
over insert a s
is the same as
the sum over s
, as long as f a = 0
.
The product of f
over insert a s
is the same as
the product over s
, as long as f a = 1
.
Adding the sums of a function over s
and over sᶜ
gives the whole sum.
For a version expressed with subtypes, see Fintype.sum_subtype_add_sum_subtype
.
Multiplying the products of a function over s
and over sᶜ
gives the whole product.
For a version expressed with subtypes, see Fintype.prod_subtype_mul_prod_subtype
.
Sum over a sigma type equals the sum of fiberwise sums. For rewriting
in the reverse direction, use Finset.sum_sigma'
Product over a sigma type equals the product of fiberwise products. For rewriting
in the reverse direction, use Finset.prod_sigma'
.
Reorder a sum.
The difference with sum_bij'
is that the bijection is specified as a surjective injection,
rather than by an inverse function.
Reorder a product.
The difference with prod_bij'
is that the bijection is specified as a surjective injection,
rather than by an inverse function.
Reorder a sum.
The difference with sum_bij
is that the bijection is specified with an inverse, rather than
as a surjective injection.
Reorder a product.
The difference with prod_bij
is that the bijection is specified with an inverse, rather than
as a surjective injection.
Reindexing a sum over a finset along an equivalence.
See Equiv.sum_comp
for the version where s
and s'
are univ
.
Reindexing a product over a finset along an equivalence.
See Equiv.prod_comp
for the version where s
and s'
are univ
.
Equations
- Finset.sum_image'.match_1 _x motive x h_1 = Exists.casesOn x fun w h => And.casesOn h fun left right => h_1 w left right
Instances For
An uncurried version of Finset.sum_product
An uncurried version of Finset.prod_product
.
An uncurried version of Finset.prod_product_right
An uncurried version of Finset.prod_product_right
.
Generalization of Finset.sum_comm
to the case when the inner Finset
s depend on
the outer variable.
Equations
- Finset.sum_comm'.match_1 motive x h_1 = Prod.casesOn x fun fst snd => h_1 fst snd
Instances For
Generalization of Finset.prod_comm
to the case when the inner Finset
s depend on the outer
variable.
A sum over s.subtype p
equals one over s.filter p
.
A product over s.subtype p
equals one over s.filter p
.
If all elements of a Finset
satisfy the predicate p
, a sum
over s.subtype p
equals that sum over s
.
If all elements of a Finset
satisfy the predicate p
, a product
over s.subtype p
equals that product over s
.
A sum of a function over a Finset
in a subtype equals a
sum in the main type of a function that agrees with the first
function on that Finset
.
A product of a function over a Finset
in a subtype equals a
product in the main type of a function that agrees with the first
function on that Finset
.
Equations
- Finset.sum_congr_set.match_1 s motive x x h_1 = Subtype.casesOn β (fun x => x ∈ s) (fun x => (x_1 : x ∈ Finset.univ) → motive x x_1) x (fun val property x => h_1 val property x) x
Instances For
The sum of a function g
defined only on a set s
is equal to
the sum of a function f
defined everywhere,
as long as f
and g
agree on s
, and f = 0
off s
.
The product of a function g
defined only on a set s
is equal to
the product of a function f
defined everywhere,
as long as f
and g
agree on s
, and f = 1
off s
.
A sum taken over a conditional whose condition is an equality
test on the index and whose alternative is 0
has value either the term at that index or 0
.
The difference with Finset.sum_ite_eq
is that the arguments to eq
are swapped.
A product taken over a conditional whose condition is an equality test on the index and whose
alternative is 1
has value either the term at that index or 1
.
The difference with Finset.prod_ite_eq
is that the arguments to Eq
are swapped.
Equations
- Finset.sum_range_succ'.match_1 motive x h_1 h_2 = Nat.casesOn x (h_1 ()) fun n => h_2 n
Instances For
To prove a property of a sum, it suffices to prove that the property is additive and holds on summands.
To prove a property of a product, it suffices to prove that the property is multiplicative and holds on factors.
To prove a property of a sum, it suffices to prove that the property is additive and holds on summands.
To prove a property of a product, it suffices to prove that the property is multiplicative and holds on factors.
For any sum along {0, ..., n - 1}
of a commutative-monoid-valued function, we can
verify that it's equal to a different function just by checking differences of adjacent terms.
This is a discrete analogue of the fundamental theorem of calculus.
For any product along {0, ..., n - 1}
of a commutative-monoid-valued function, we can verify
that it's equal to a different function just by checking ratios of adjacent terms.
This is a multiplicative discrete analogue of the fundamental theorem of calculus.
A telescoping sum along {0, ..., n - 1}
of an additive commutative group valued
function reduces to the difference of the last and first terms.
A telescoping product along {0, ..., n - 1}
of a commutative group valued function reduces to
the ratio of the last and first factors.
A telescoping sum along {0, ..., n-1}
of an ℕ
-valued function
reduces to the difference of the last and first terms
when the function we are summing is monotone.
A sum over Finset.powersetLen
which only depends on the size of the sets is constant.
A product over Finset.powersetLen
which only depends on the size of the sets is constant.
Equations
- Finset.sum_involution.match_1 s motive x h_1 = Exists.casesOn x fun w h => h_1 w h
Instances For
The sum of the composition of functions f
and g
, is the sum over b ∈ s.image g
of f b
times of the cardinality of the fibre of b
. See also Finset.sum_image
.
The product of the composition of functions f
and g
, is the product over b ∈ s.image g
of
f b
to the power of the cardinality of the fibre of b
. See also Finset.prod_image
.
A sum can be partitioned into a sum of sums, each equivalent under a setoid.
A product can be partitioned into a product of products, each equivalent under a setoid.
If we can partition a sum into subsets that cancel out, then the whole sum cancels.
If we can partition a product into subsets that cancel out, then the whole product cancels.
If a sum of a Finset
of size at most 1 has a given
value, so do the terms in that sum.
If a product of a Finset
of size at most 1 has a given value, so
do the terms in that product.
Taking a sum over s : Finset α
is the same as adding the value on a single element
f a
to the sum over s.erase a
.
See Multiset.sum_map_erase
for the Multiset
version.
Taking a product over s : Finset α
is the same as multiplying the value on a single element
f a
by the product of s.erase a
.
See Multiset.prod_map_erase
for the Multiset
version.
A variant of Finset.add_sum_erase
with the addition swapped.
A variant of Finset.mul_prod_erase
with the multiplication swapped.
If a function applied at a point is 0, a sum is unchanged by
removing that point, if present, from a Finset
.
If a function applied at a point is 1, a product is unchanged by
removing that point, if present, from a Finset
.
See also Finset.sum_boole
.
See also Finset.prod_boole
.
If a sum is 0 and the function is 0 except possibly at one
point, it is 0 everywhere on the Finset
.
If a product is 1 and the function is 1 except possibly at one
point, it is 1 everywhere on the Finset
.
If f = g = h
everywhere but at i
, where f i = g i + h i
, then the product of f
over s
is the sum of the products of g
and h
.
Moving to the opposite additive commutative monoid commutes with summing.
Fintype.sum_equiv
is a variant of Finset.sum_bij
that accepts
Function.bijective
.
See Function.bijective.sum_comp
for a version without h
.
Fintype.prod_bijective
is a variant of Finset.prod_bij
that accepts Function.bijective
.
See Function.bijective.prod_comp
for a version without h
.
Fintype.sum_equiv
is a specialization of Finset.sum_bij
that
automatically fills in most arguments.
See Equiv.sum_comp
for a version without h
.
Fintype.prod_equiv
is a specialization of Finset.prod_bij
that
automatically fills in most arguments.
See Equiv.prod_comp
for a version without h
.
Equations
- List.sum_toFinset.match_2 a l motive x h_1 = And.casesOn x fun left right => h_1 left right
Instances For
Equations
- List.sum_toFinset.match_1 motive x x h_1 h_2 = List.casesOn α (fun x => (x_1 : List.Nodup x) → motive x x_1) x (fun x => h_1 x) (fun head tail x => h_2 head tail x) x