Indicator function #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
indicator (s : set α) (f : α → β) (a : α)
isf a
ifa ∈ s
and is0
otherwise.mul_indicator (s : set α) (f : α → β) (a : α)
isf a
ifa ∈ s
and is1
otherwise.
Implementation note #
In mathematics, an indicator function or a characteristic function is a function
used to indicate membership of an element in a set s
,
having the value 1
for all elements of s
and the value 0
otherwise.
But since it is usually used to restrict a function to a certain set s
,
we let the indicator function take the value f x
for some function f
, instead of 1
.
If the usual indicator function is needed, just set f
to be the constant function λx, 1
.
The indicator function is implemented non-computably, to avoid having to pass around decidable
arguments. This is in contrast with the design of pi.single
or set.piecewise
.
Tags #
indicator, characteristic
If a multiplicative indicator function is not equal to 1
at a point, then that point is in the
set.
set.mul_indicator
as a monoid_hom
.
Equations
- set.mul_indicator_hom M s = {to_fun := s.mul_indicator, map_one' := _, map_mul' := _}
set.indicator
as an add_monoid_hom
.
Consider a product of g i (f i)
over a finset
. Suppose g
is a
function such as pow
, which maps a second argument of 1
to
1
. Then if f
is replaced by the corresponding multiplicative indicator
function, the finset
may be replaced by a possibly larger finset
without changing the value of the sum.
Consider a sum of g i (f i)
over a finset
. Suppose g
is a
function such as multiplication, which maps a second argument of 0 to
0. (A typical use case would be a weighted sum of f i * h i
or f i • h i
, where f
gives the weights that are multiplied by some other
function h
.) Then if f
is replaced by the corresponding indicator
function, the finset
may be replaced by a possibly larger finset
without changing the value of the sum.
Taking the product of an indicator function over a possibly larger finset
is the same as
taking the original function over the original finset
.
Summing an indicator function over a possibly larger finset
is the same as summing
the original function over the original finset
.