mathlib documentation

data.​indicator_function

data.​indicator_function

Indicator function

indicator (s : set α) (f : α → β) (a : α) is f a if a ∈ s and is 0 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.

Tags

indicator, characteristic

def set.​indicator {α : Type u} {β : Type v} [has_zero β] :
set α(α → β)α → β

indicator s f a is f a if a ∈ s, 0 otherwise.

Equations
theorem set.​indicator_apply {α : Type u} {β : Type v} [has_zero β] (s : set α) (f : α → β) (a : α) :
s.indicator f a = ite (a s) (f a) 0

@[simp]
theorem set.​indicator_of_mem {α : Type u} {β : Type v} [has_zero β] {s : set α} {a : α} (h : a s) (f : α → β) :
s.indicator f a = f a

@[simp]
theorem set.​indicator_of_not_mem {α : Type u} {β : Type v} [has_zero β] {s : set α} {a : α} (h : a s) (f : α → β) :
s.indicator f a = 0

theorem set.​mem_of_indicator_ne_zero {α : Type u} {β : Type v} [has_zero β] {s : set α} {f : α → β} {a : α} :
s.indicator f a 0a s

If an indicator function is nonzero at a point, that point is in the set.

theorem set.​eq_on_indicator {α : Type u} {β : Type v} [has_zero β] {s : set α} {f : α → β} :

theorem set.​support_indicator {α : Type u} {β : Type v} [has_zero β] {s : set α} {f : α → β} :

@[simp]
theorem set.​indicator_range_comp {α : Type u} {β : Type v} [has_zero β] {ι : Sort u_1} (f : ι → α) (g : α → β) :

theorem set.​indicator_congr {α : Type u} {β : Type v} [has_zero β] {s : set α} {f g : α → β} :
(∀ (a : α), a sf a = g a)s.indicator f = s.indicator g

@[simp]
theorem set.​indicator_univ {α : Type u} {β : Type v} [has_zero β] (f : α → β) :

@[simp]
theorem set.​indicator_empty {α : Type u} {β : Type v} [has_zero β] (f : α → β) :
.indicator f = λ (a : α), 0

@[simp]
theorem set.​indicator_zero {α : Type u} (β : Type v) [has_zero β] (s : set α) :
s.indicator (λ (x : α), 0) = λ (x : α), 0

theorem set.​indicator_indicator {α : Type u} {β : Type v} [has_zero β] (s t : set α) (f : α → β) :

theorem set.​indicator_comp_of_zero {α : Type u} {β : Type v} [has_zero β] {s : set α} {f : α → β} {γ : Type u_1} [has_zero γ] {g : β → γ} :
g 0 = 0s.indicator (g f) = g s.indicator f

theorem set.​indicator_preimage {α : Type u} {β : Type v} [has_zero β] (s : set α) (f : α → β) (B : set β) :
s.indicator f ⁻¹' B = s f ⁻¹' B s (λ (a : α), 0) ⁻¹' B

theorem set.​indicator_preimage_of_not_mem {α : Type u} {β : Type v} [has_zero β] (s : set α) (f : α → β) {t : set β} :
0 ts.indicator f ⁻¹' t = s f ⁻¹' t

theorem set.​mem_range_indicator {α : Type u} {β : Type v} [has_zero β] {r : β} {s : set α} {f : α → β} :

theorem set.​indicator_rel_indicator {α : Type u} {β : Type v} [has_zero β] {s : set α} {f g : α → β} {a : α} {r : β → β → Prop} :
r 0 0(a sr (f a) (g a))r (s.indicator f a) (s.indicator g a)

theorem set.​sum_indicator_subset_of_eq_zero {α : Type u} {β : Type v} [has_zero β] {γ : Type u_1} [add_comm_monoid γ] (f : α → β) (g : α → β → γ) {s₁ s₂ : finset α} :
s₁ s₂(∀ (a : α), g a 0 = 0)s₁.sum (λ (i : α), g i (f i)) = s₂.sum (λ (i : α), g i (s₁.indicator f i))

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

  1. (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.
theorem set.​sum_indicator_subset {α : Type u} {γ : Type u_1} [add_comm_monoid γ] (f : α → γ) {s₁ s₂ : finset α} :
s₁ s₂s₁.sum (λ (i : α), f i) = s₂.sum (λ (i : α), s₁.indicator f i)

Summing an indicator function over a possibly larger finset is the same as summing the original function over the original finset.

theorem set.​indicator_union_of_not_mem_inter {α : Type u} {β : Type v} [add_monoid β] {s t : set α} {a : α} (h : a s t) (f : α → β) :
(s t).indicator f a = s.indicator f a + t.indicator f a

theorem set.​indicator_union_of_disjoint {α : Type u} {β : Type v} [add_monoid β] {s t : set α} (h : disjoint s t) (f : α → β) :
(s t).indicator f = λ (a : α), s.indicator f a + t.indicator f a

theorem set.​indicator_add {α : Type u} {β : Type v} [add_monoid β] (s : set α) (f g : α → β) :
s.indicator (λ (a : α), f a + g a) = λ (a : α), s.indicator f a + s.indicator g a

@[simp]
theorem set.​indicator_compl_add_self_apply {α : Type u} {β : Type v} [add_monoid β] (s : set α) (f : α → β) (a : α) :
s.indicator f a + s.indicator f a = f a

@[simp]
theorem set.​indicator_compl_add_self {α : Type u} {β : Type v} [add_monoid β] (s : set α) (f : α → β) :

@[simp]
theorem set.​indicator_self_add_compl_apply {α : Type u} {β : Type v} [add_monoid β] (s : set α) (f : α → β) (a : α) :
s.indicator f a + s.indicator f a = f a

@[simp]
theorem set.​indicator_self_add_compl {α : Type u} {β : Type v} [add_monoid β] (s : set α) (f : α → β) :

@[instance]
def set.​is_add_monoid_hom.​indicator {α : Type u} (β : Type v) [add_monoid β] (s : set α) :
is_add_monoid_hom (λ (f : α → β), s.indicator f)

Equations
  • _ = _
theorem set.​indicator_smul {α : Type u} {β : Type v} [add_monoid β] {𝕜 : Type u_1} [monoid 𝕜] [distrib_mul_action 𝕜 β] (s : set α) (r : 𝕜) (f : α → β) :
s.indicator (λ (x : α), r f x) = λ (x : α), r s.indicator f x

@[instance]
def set.​is_add_group_hom.​indicator {α : Type u} (β : Type v) [add_group β] (s : set α) :
is_add_group_hom (λ (f : α → β), s.indicator f)

Equations
theorem set.​indicator_neg {α : Type u} {β : Type v} [add_group β] (s : set α) (f : α → β) :
s.indicator (λ (a : α), -f a) = λ (a : α), -s.indicator f a

theorem set.​indicator_sub {α : Type u} {β : Type v} [add_group β] (s : set α) (f g : α → β) :
s.indicator (λ (a : α), f a - g a) = λ (a : α), s.indicator f a - s.indicator g a

theorem set.​indicator_compl {α : Type u} {β : Type v} [add_group β] (s : set α) (f : α → β) :

theorem set.​indicator_finset_sum {α : Type u} {β : Type u_1} [add_comm_monoid β] {ι : Type u_2} (I : finset ι) (s : set α) (f : ι → α → β) :
s.indicator (I.sum (λ (i : ι), f i)) = I.sum (λ (i : ι), s.indicator (f i))

theorem set.​indicator_finset_bUnion {α : Type u} {β : Type u_1} [add_comm_monoid β] {ι : Type u_2} (I : finset ι) (s : ι → set α) {f : α → β} :
(∀ (i : ι), i I∀ (j : ι), j Ii js i s j = )((⋃ (i : ι) (H : i I), s i).indicator f = λ (a : α), I.sum (λ (i : ι), (s i).indicator f a))

theorem set.​indicator_mul {α : Type u} {β : Type v} [mul_zero_class β] (s : set α) (f g : α → β) :
s.indicator (λ (a : α), f a * g a) = λ (a : α), s.indicator f a * s.indicator g a

theorem set.​indicator_nonneg' {α : Type u} {β : Type v} [has_zero β] [preorder β] {s : set α} {f : α → β} {a : α} :
(a s0 f a)0 s.indicator f a

theorem set.​indicator_nonneg {α : Type u} {β : Type v} [has_zero β] [preorder β] {s : set α} {f : α → β} (h : ∀ (a : α), a s0 f a) (a : α) :
0 s.indicator f a

theorem set.​indicator_nonpos' {α : Type u} {β : Type v} [has_zero β] [preorder β] {s : set α} {f : α → β} {a : α} :
(a sf a 0)s.indicator f a 0

theorem set.​indicator_nonpos {α : Type u} {β : Type v} [has_zero β] [preorder β] {s : set α} {f : α → β} (h : ∀ (a : α), a sf a 0) (a : α) :
s.indicator f a 0

theorem set.​indicator_le' {α : Type u} {β : Type v} [has_zero β] [preorder β] {s : set α} {f g : α → β} :
(∀ (a : α), a sf a g a)(∀ (a : α), a s0 g a)s.indicator f g

theorem set.​indicator_le_indicator {α : Type u} {β : Type v} [has_zero β] [preorder β] {s : set α} {f g : α → β} {a : α} :
f a g as.indicator f a s.indicator g a

theorem set.​indicator_le_indicator_of_subset {α : Type u} {β : Type v} [has_zero β] [preorder β] {s t : set α} {f : α → β} (h : s t) (hf : ∀ (a : α), 0 f a) (a : α) :
s.indicator f a t.indicator f a

theorem set.​indicator_le_self' {α : Type u} {β : Type v} [has_zero β] [preorder β] {s : set α} {f : α → β} :
(∀ (x : α), x s0 f x)s.indicator f f

theorem set.​indicator_le_self {α : Type u} {β : Type u_1} [canonically_ordered_add_monoid β] (s : set α) (f : α → β) :

theorem set.​indicator_le {α : Type u} {β : Type u_1} [canonically_ordered_add_monoid β] {s : set α} {f g : α → β} :
(∀ (a : α), a sf a g a)s.indicator f g

theorem add_monoid_hom.​map_indicator {α : Type u} {M : Type u_1} {N : Type u_2} [add_monoid M] [add_monoid N] (f : M →+ N) (s : set α) (g : α → M) (x : α) :
f (s.indicator g x) = s.indicator (f g) x