Indicator function #
Set.indicator (s : Set α) (f : α → β) (a : α)
isf a
ifa ∈ s
and is0
otherwise.Set.mulIndicator (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 fun _ ↦ 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
Set.indicator s f a
is f a
if a ∈ s
, 0
otherwise.
Equations
- Set.indicator s f x = if x ∈ s then f x else 0
Instances For
Set.mulIndicator s f a
is f a
if a ∈ s
, 1
otherwise.
Equations
- Set.mulIndicator s f x = if x ∈ s then f x else 1
Instances For
If an additive indicator function is not equal to 0
at a point, then that point is
in the set.
If a multiplicative indicator function is not equal to 1
at a point, then that point is in the
set.
Set.indicator
as an addMonoidHom
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Set.mulIndicator
as a monoidHom
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
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.
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.
Summing an indicator function over a possibly larger Finset
is the same as summing
the original function over the original finset
.
Taking the product of an indicator function over a possibly larger Finset
is the same as
taking the original function over the original Finset
.