The areas / V03. Sets, finite structures and big operators
Mathlib.Algebra.BigOperators.Expect
64 declarations. Mathlib docs · Source
Average over a finset
This file defines Finset.expect, the average (aka expectation) of a function over a finset.
Notation
𝔼 i ∈ s, f iis notation forFinset.expect s f. It is the expectation off iwhereiranges over the finite sets(either aFinsetor aSetwith aFintypeinstance).𝔼 i, f iis notation forFinset.expect Finset.univ f. It is the expectation off iwhereiranges over the finite domain off.𝔼 i ∈ s with p i, f iis notation forFinset.expect (Finset.filter p s) f. This is referred to asexpectWithin lemma names.𝔼 (i ∈ s) (j ∈ t), f i jis notation forFinset.expect (s ×ˢ t) (fun ⟨i, j⟩ ↦ f i j).
Implementation notes
This definition is a special case of the general convex combination operator in a convex space. However:
- We don't yet have general convex spaces.
- The uniform weights case is an overwhelmingly useful special case which should have its own API.
When convex spaces are finally defined, we should redefine Finset.expect in terms of that convex
combination operator.
TODO
- Connect
Finset.expectwith the expectation oversin the probability theory sense. - Give a formulation of Jensen's inequality in this language.
def Finset.expect E1 #
{ι : Type u_1} → {M : Type u_4} → [inst : AddCommMonoid M] → [Module ℚ≥0 M] → Finset ι → (ι → M) → M
Average of a function over a finset. If the finset is empty, this is equal to zero.
def BigOperators.bigexpect E1 #
Lean.ParserDescr
𝔼 i ∈ s, f iis notation forFinset.expect s f. It is the expectation off iwhereiranges over the finite sets(either aFinsetor aSetwith aFintypeinstance).𝔼 i, f iis notation forFinset.expect Finset.univ f. It is the expectation off iwhereiranges over the finite domain off.𝔼 i ∈ s with p i, f iis notation forFinset.expect (Finset.filter p s) f.𝔼 (i ∈ s) (j ∈ t), f i jis notation forFinset.expect (s ×ˢ t) (fun ⟨i, j⟩ ↦ f i j).
These support destructuring, for example 𝔼 ⟨i, j⟩ ∈ s ×ˢ t, f i j.
Notation: "𝔼" bigOpBinders* ("with" term)? "," term
def BigOperators.delabFinsetExpect E1 #
Lean.PrettyPrinter.Delaborator.Delab
Delaborator for Finset.expect. The pp.funBinderTypes option controls whether
to show the domain type when the expect is over Finset.univ.
theorem Finset.expect_univ E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {f : ι → M} [inst_2 : Fintype ι],
(Finset.univ.expect fun i ↦ f i) = (↑(Fintype.card ι))⁻¹ • ∑ i, f i
theorem Finset.expect_empty E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] (f : ι → M), (∅.expect fun i ↦ f i) = 0
theorem Finset.expect_singleton E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] (f : ι → M) (i : ι),
({i}.expect fun j ↦ f j) = f i
theorem Finset.expect_const_zero E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] (s : Finset ι),
(s.expect fun _i ↦ 0) = 0
theorem Finset.expect_congr E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι} {f g : ι → M}
{t : Finset ι}, s = t → (∀ i ∈ t, f i = g i) → (s.expect fun i ↦ f i) = t.expect fun i ↦ g i
theorem Finset.expectWith_congr E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s t : Finset ι} {f g : ι → M}
{p q : ι → Prop} [inst_2 : DecidablePred p] [inst_3 : DecidablePred q],
s = t →
(∀ i ∈ t, p i ↔ q i) →
(∀ i ∈ t, q i → f i = g i) → ({i ∈ s | p i}.expect fun i ↦ f i) = {i ∈ t | q i}.expect fun i ↦ g i
theorem Finset.expect_sum_comm E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] (s : Finset ι)
(t : Finset κ) (f : ι → κ → M), (s.expect fun i ↦ ∑ j ∈ t, f i j) = ∑ j ∈ t, s.expect fun i ↦ f i j
theorem Finset.expect_comm E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] (s : Finset ι)
(t : Finset κ) (f : ι → κ → M), (s.expect fun i ↦ t.expect fun j ↦ f i j) = t.expect fun j ↦ s.expect fun i ↦ f i j
theorem Finset.expect_eq_zero E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι} {f : ι → M},
(∀ i ∈ s, f i = 0) → (s.expect fun i ↦ f i) = 0
theorem Finset.exists_ne_zero_of_expect_ne_zero E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι} {f : ι → M},
(s.expect fun i ↦ f i) ≠ 0 → ∃ i ∈ s, f i ≠ 0
theorem Finset.expect_add_distrib E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] (s : Finset ι) (f g : ι → M),
(s.expect fun i ↦ f i + g i) = (s.expect fun i ↦ f i) + s.expect fun i ↦ g i
theorem Finset.expect_add_expect_comm E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι} (f₁ f₂ g₁ g₂ : ι → M),
((s.expect fun i ↦ f₁ i + f₂ i) + s.expect fun i ↦ g₁ i + g₂ i) =
(s.expect fun i ↦ f₁ i + g₁ i) + s.expect fun i ↦ f₂ i + g₂ i
theorem Finset.expect_eq_single_of_mem E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι} {f : ι → M},
∀ i ∈ s, (∀ j ∈ s, j ≠ i → f j = 0) → (s.expect fun i ↦ f i) = (↑s.card)⁻¹ • f i
theorem Finset.expect_ite_zero E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] (s : Finset ι) (p : ι → Prop)
[inst_2 : DecidablePred p],
(∀ i ∈ s, ∀ j ∈ s, p i → p j → i = j) →
∀ (a : M), (s.expect fun i ↦ if p i then a else 0) = if ∃ i ∈ s, p i then (↑s.card)⁻¹ • a else 0
theorem Finset.expect_ite_mem E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] [inst_2 : DecidableEq ι]
(s t : Finset ι) (f : ι → M),
(s.expect fun i ↦ if i ∈ t then f i else 0) = (↑(s ∩ t).card / ↑s.card) • (s ∩ t).expect fun i ↦ f i
theorem Finset.expect_dite_eq E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι} [inst_2 : DecidableEq ι]
(i : ι) (f : (j : ι) → i = j → M),
(s.expect fun j ↦ if h : i = j then f j h else 0) = if i ∈ s then (↑s.card)⁻¹ • f i ⋯ else 0
theorem Finset.expect_dite_eq' E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι} [inst_2 : DecidableEq ι]
(i : ι) (f : (j : ι) → j = i → M),
(s.expect fun j ↦ if h : j = i then f j h else 0) = if i ∈ s then (↑s.card)⁻¹ • f i ⋯ else 0
theorem Finset.expect_ite_eq E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι} [inst_2 : DecidableEq ι]
(i : ι) (f : ι → M), (s.expect fun j ↦ if i = j then f j else 0) = if i ∈ s then (↑s.card)⁻¹ • f i else 0
theorem Finset.expect_ite_eq' E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι} [inst_2 : DecidableEq ι]
(i : ι) (f : ι → M), (s.expect fun j ↦ if j = i then f j else 0) = if i ∈ s then (↑s.card)⁻¹ • f i else 0
theorem Finset.expect_bij E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι}
{f : ι → M} {t : Finset κ} {g : κ → M} (i : (a : ι) → a ∈ s → κ),
(∀ (a : ι) (ha : a ∈ s), i a ha ∈ t) →
(∀ (a : ι) (ha : a ∈ s), f a = g (i a ha)) →
(∀ (a₁ : ι) (ha₁ : a₁ ∈ s) (a₂ : ι) (ha₂ : a₂ ∈ s), i a₁ ha₁ = i a₂ ha₂ → a₁ = a₂) →
(∀ b ∈ t, ∃ a, ∃ (ha : a ∈ s), i a ha = b) → (s.expect fun i ↦ f i) = t.expect fun i ↦ g i
Reorder an average.
The difference with Finset.expect_bij' is that the bijection is specified as a surjective
injection, rather than by an inverse function.
The difference with Finset.expect_nbij is that the bijection is allowed to use membership of the
domain of the average, rather than being a non-dependent function.
theorem Finset.expect_bij' E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι}
{f : ι → M} {t : Finset κ} {g : κ → M} (i : (a : ι) → a ∈ s → κ) (j : (a : κ) → a ∈ t → ι)
(hi : ∀ (a : ι) (ha : a ∈ s), i a ha ∈ t) (hj : ∀ (a : κ) (ha : a ∈ t), j a ha ∈ s),
(∀ (a : ι) (ha : a ∈ s), j (i a ha) ⋯ = a) →
(∀ (a : κ) (ha : a ∈ t), i (j a ha) ⋯ = a) →
(∀ (a : ι) (ha : a ∈ s), f a = g (i a ha)) → (s.expect fun i ↦ f i) = t.expect fun i ↦ g i
Reorder an average.
The difference with Finset.expect_bij is that the bijection is specified with an inverse, rather
than as a surjective injection.
The difference with Finset.expect_nbij' is that the bijection and its inverse are allowed to use
membership of the domains of the averages, rather than being non-dependent functions.
theorem Finset.expect_nbij E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι}
{f : ι → M} {t : Finset κ} {g : κ → M} (i : ι → κ),
(∀ a ∈ s, i a ∈ t) →
(∀ a ∈ s, f a = g (i a)) → Set.InjOn i ↑s → Set.SurjOn i ↑s ↑t → (s.expect fun i ↦ f i) = t.expect fun i ↦ g i
Reorder an average.
The difference with Finset.expect_nbij' is that the bijection is specified as a surjective
injection, rather than by an inverse function.
The difference with Finset.expect_bij is that the bijection is a non-dependent function, rather
than being allowed to use membership of the domain of the average.
theorem Finset.expect_nbij' E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι}
{f : ι → M} {t : Finset κ} {g : κ → M} (i : ι → κ) (j : κ → ι),
(∀ a ∈ s, i a ∈ t) →
(∀ a ∈ t, j a ∈ s) →
(∀ a ∈ s, j (i a) = a) →
(∀ a ∈ t, i (j a) = a) → (∀ a ∈ s, f a = g (i a)) → (s.expect fun i ↦ f i) = t.expect fun i ↦ g i
Reorder an average.
The difference with Finset.expect_nbij is that the bijection is specified with an inverse, rather
than as a surjective injection.
The difference with Finset.expect_bij' is that the bijection and its inverse are non-dependent
functions, rather than being allowed to use membership of the domains of the averages.
The difference with Finset.expect_equiv is that bijectivity is only required to hold on the
domains of the averages, rather than on the entire types.
theorem Finset.expect_equiv E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι}
{f : ι → M} {t : Finset κ} {g : κ → M} (e : ι ≃ κ),
(∀ (i : ι), i ∈ s ↔ e i ∈ t) → (∀ i ∈ s, f i = g (e i)) → (s.expect fun i ↦ f i) = t.expect fun i ↦ g i
Finset.expect_equiv is a specialization of Finset.expect_bij that automatically fills in
most arguments.
theorem Finset.expect_product E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] (s : Finset ι)
(t : Finset κ) (f : ι × κ → M), ((s ×ˢ t).expect fun x ↦ f x) = s.expect fun i ↦ t.expect fun j ↦ f (i, j)
Expectation over a product set equals the expectation of the fiberwise expectations.
For rewriting in the reverse direction, use Finset.expect_product'.
theorem Finset.expect_product' E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] (s : Finset ι)
(t : Finset κ) (f : ι → κ → M), ((s ×ˢ t).expect fun i ↦ f i.1 i.2) = s.expect fun i ↦ t.expect fun j ↦ f i j
Expectation over a product set equals the expectation of the fiberwise expectations.
For rewriting in the reverse direction, use Finset.expect_product.
theorem Finset.expect_image E0 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {f : ι → M}
{t : Finset κ} [inst_2 : DecidableEq ι] {m : κ → ι},
Set.InjOn m ↑t → ((Finset.image m t).expect fun i ↦ f i) = t.expect fun i ↦ f (m i)
theorem Finset.expect_inv_index E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] [inst_2 : DecidableEq ι]
[inst_3 : InvolutiveInv ι] (s : Finset ι) (f : ι → M), (s⁻¹.expect fun i ↦ f i) = s.expect fun i ↦ f i⁻¹
theorem Finset.expect_neg_index E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] [inst_2 : DecidableEq ι]
[inst_3 : InvolutiveNeg ι] (s : Finset ι) (f : ι → M), ((-s).expect fun i ↦ f i) = s.expect fun i ↦ f (-i)
theorem map_expect E0 #
∀ {ι : Type u_1} {M : Type u_4} {N : Type u_5} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M]
[inst_2 : AddCommMonoid N] [inst_3 : Module ℚ≥0 N] {F : Type u_6} [inst_4 : FunLike F M N] [LinearMapClass F ℚ≥0 M N]
(g : F) (f : ι → M) (s : Finset ι), g (s.expect fun i ↦ f i) = s.expect fun i ↦ g (f i)
theorem Finset.card_smul_expect E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] (s : Finset ι) (f : ι → M),
(s.card • s.expect fun i ↦ f i) = ∑ i ∈ s, f i
theorem Fintype.card_smul_expect E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] [inst_2 : Fintype ι] (f : ι → M),
(Fintype.card ι • Finset.univ.expect fun i ↦ f i) = ∑ i, f i
theorem Finset.expect_const E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {s : Finset ι},
s.Nonempty → ∀ (a : M), (s.expect fun _i ↦ a) = a
theorem Finset.smul_expect E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : Module ℚ≥0 M] {G : Type u_6}
[inst_2 : DistribSMul G M] [SMulCommClass G ℚ≥0 M] (a : G) (s : Finset ι) (f : ι → M),
(a • s.expect fun i ↦ f i) = s.expect fun i ↦ a • f i
theorem Finset.expect_sub_distrib E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommGroup M] [inst_1 : Module ℚ≥0 M] (s : Finset ι) (f g : ι → M),
(s.expect fun i ↦ f i - g i) = (s.expect fun i ↦ f i) - s.expect fun i ↦ g i
theorem Finset.expect_neg_distrib E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : AddCommGroup M] [inst_1 : Module ℚ≥0 M] (s : Finset ι) (f : ι → M),
(s.expect fun i ↦ -f i) = -s.expect fun i ↦ f i
theorem Finset.card_mul_expect E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Semiring M] [inst_1 : Module ℚ≥0 M] (s : Finset ι) (f : ι → M),
(↑s.card * s.expect fun i ↦ f i) = ∑ i ∈ s, f i
theorem Fintype.card_mul_expect E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Semiring M] [inst_1 : Module ℚ≥0 M] [inst_2 : Fintype ι] (f : ι → M),
(↑(Fintype.card ι) * Finset.univ.expect fun i ↦ f i) = ∑ i, f i
theorem Finset.expect_mul E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Semiring M] [inst_1 : Module ℚ≥0 M] [IsScalarTower ℚ≥0 M M] (s : Finset ι)
(f : ι → M) (a : M), (s.expect fun i ↦ f i) * a = s.expect fun i ↦ f i * a
theorem Finset.mul_expect E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Semiring M] [inst_1 : Module ℚ≥0 M] [SMulCommClass ℚ≥0 M M] (s : Finset ι)
(f : ι → M) (a : M), (a * s.expect fun i ↦ f i) = s.expect fun i ↦ a * f i
theorem Finset.expect_mul_expect E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : Semiring M] [inst_1 : Module ℚ≥0 M] [IsScalarTower ℚ≥0 M M]
[SMulCommClass ℚ≥0 M M] (s : Finset ι) (t : Finset κ) (f : ι → M) (g : κ → M),
((s.expect fun i ↦ f i) * t.expect fun j ↦ g j) = s.expect fun i ↦ t.expect fun j ↦ f i * g j
theorem Finset.expect_pow E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : CommSemiring M] [inst_1 : Module ℚ≥0 M] [IsScalarTower ℚ≥0 M M] (s : Finset ι)
(f : ι → M) (n : ℕ), (s.expect fun i ↦ f i) ^ n = (Fintype.piFinset fun x ↦ s).expect fun p ↦ ∏ i, f (p i)
theorem Finset.expect_indicator_one E0 #
∀ {ι : Type u_1} {K : Type u_3} [inst : Semifield K] [inst_1 : CharZero K] [inst_2 : Fintype ι] (s : Finset ι),
(Finset.univ.expect fun i ↦ (↑s).indicator 1 i) = ↑s.dens
theorem Finset.expect_boole_mul E1 #
∀ {ι : Type u_1} {K : Type u_3} [inst : Semifield K] [inst_1 : CharZero K] [inst_2 : Fintype ι] [Nonempty ι]
[inst_4 : DecidableEq ι] (f : ι → K) (i : ι),
(Finset.univ.expect fun j ↦ (if i = j then ↑(Fintype.card ι) else 0) * f j) = f i
theorem Finset.expect_boole_mul' E1 #
∀ {ι : Type u_1} {K : Type u_3} [inst : Semifield K] [inst_1 : CharZero K] [inst_2 : Fintype ι] [Nonempty ι]
[inst_4 : DecidableEq ι] (f : ι → K) (i : ι),
(Finset.univ.expect fun j ↦ (if j = i then ↑(Fintype.card ι) else 0) * f j) = f i
theorem Finset.expect_eq_sum_div_card E1 #
∀ {ι : Type u_1} {K : Type u_3} [inst : Semifield K] [inst_1 : CharZero K] (s : Finset ι) (f : ι → K),
(s.expect fun i ↦ f i) = (∑ i ∈ s, f i) / ↑s.card
theorem Fintype.expect_eq_sum_div_card E1 #
∀ {ι : Type u_1} {K : Type u_3} [inst : Semifield K] [inst_1 : CharZero K] [inst_2 : Fintype ι] (f : ι → K),
(Finset.univ.expect fun i ↦ f i) = (∑ i, f i) / ↑(Fintype.card ι)
theorem Finset.expect_div E1 #
∀ {ι : Type u_1} {K : Type u_3} [inst : Semifield K] [inst_1 : CharZero K] (s : Finset ι) (f : ι → K) (a : K),
(s.expect fun i ↦ f i) / a = s.expect fun i ↦ f i / a
theorem Finset.expect_apply E0 #
∀ {ι : Type u_1} {α : Type u_6} {π : α → Type u_7} [inst : (a : α) → CommSemiring (π a)]
[inst_1 : (a : α) → Module ℚ≥0 (π a)] (s : Finset ι) (f : ι → (a : α) → π a) (a : α),
s.expect (fun i ↦ f i) a = s.expect fun i ↦ f i a
theorem algebraMap.coe_expect E0 #
∀ {ι : Type u_1} {M : Type u_4} {N : Type u_5} [inst : Semifield M] [inst_1 : CharZero M] [inst_2 : Semifield N]
[inst_3 : CharZero N] [inst_4 : Algebra M N] (s : Finset ι) (f : ι → M),
↑(s.expect fun i ↦ f i) = s.expect fun i ↦ ↑(f i)
theorem Fintype.expect_bijective E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : Fintype ι] [inst_1 : Fintype κ] [inst_2 : AddCommMonoid M]
[inst_3 : Module ℚ≥0 M] (e : ι → κ),
Function.Bijective e →
∀ (f : ι → M) (g : κ → M),
(∀ (i : ι), f i = g (e i)) → (Finset.univ.expect fun i ↦ f i) = Finset.univ.expect fun i ↦ g i
Fintype.expect_bijective is a variant of Finset.expect_bij that accepts
Function.Bijective.
See Function.Bijective.expect_comp for a version without h.
theorem Fintype.expect_equiv E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : Fintype ι] [inst_1 : Fintype κ] [inst_2 : AddCommMonoid M]
[inst_3 : Module ℚ≥0 M] (e : ι ≃ κ) (f : ι → M) (g : κ → M),
(∀ (i : ι), f i = g (e i)) → (Finset.univ.expect fun i ↦ f i) = Finset.univ.expect fun i ↦ g i
Fintype.expect_equiv is a specialization of Finset.expect_bij that automatically fills in
most arguments.
See Equiv.expect_comp for a version without h.
theorem Fintype.expect_const E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Fintype ι] [inst_1 : AddCommMonoid M] [inst_2 : Module ℚ≥0 M] [Nonempty ι]
(a : M), (Finset.univ.expect fun _i ↦ a) = a
theorem Fintype.expect_ite_zero E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Fintype ι] [inst_1 : AddCommMonoid M] [inst_2 : Module ℚ≥0 M] (p : ι → Prop)
[inst_3 : DecidablePred p],
(∀ (i j : ι), p i → p j → i = j) →
∀ (a : M), (Finset.univ.expect fun i ↦ if p i then a else 0) = if ∃ i, p i then (↑(Fintype.card ι))⁻¹ • a else 0
theorem Fintype.expect_ite_mem E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Fintype ι] [inst_1 : AddCommMonoid M] [inst_2 : Module ℚ≥0 M]
[inst_3 : DecidableEq ι] (s : Finset ι) (f : ι → M),
(Finset.univ.expect fun i ↦ if i ∈ s then f i else 0) = s.dens • s.expect fun i ↦ f i
theorem Fintype.expect_dite_eq E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Fintype ι] [inst_1 : AddCommMonoid M] [inst_2 : Module ℚ≥0 M]
[inst_3 : DecidableEq ι] (i : ι) (f : (j : ι) → i = j → M),
(Finset.univ.expect fun j ↦ if h : i = j then f j h else 0) = (↑(Fintype.card ι))⁻¹ • f i ⋯
theorem Fintype.expect_dite_eq' E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Fintype ι] [inst_1 : AddCommMonoid M] [inst_2 : Module ℚ≥0 M]
[inst_3 : DecidableEq ι] (i : ι) (f : (j : ι) → j = i → M),
(Finset.univ.expect fun j ↦ if h : j = i then f j h else 0) = (↑(Fintype.card ι))⁻¹ • f i ⋯
theorem Fintype.expect_ite_eq E0 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Fintype ι] [inst_1 : AddCommMonoid M] [inst_2 : Module ℚ≥0 M]
[inst_3 : DecidableEq ι] (i : ι) (f : ι → M),
(Finset.univ.expect fun j ↦ if i = j then f j else 0) = (↑(Fintype.card ι))⁻¹ • f i
theorem Fintype.expect_ite_eq' E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Fintype ι] [inst_1 : AddCommMonoid M] [inst_2 : Module ℚ≥0 M]
[inst_3 : DecidableEq ι] (i : ι) (f : ι → M),
(Finset.univ.expect fun j ↦ if j = i then f j else 0) = (↑(Fintype.card ι))⁻¹ • f i
theorem Fintype.expect_one E1 #
∀ {ι : Type u_1} {M : Type u_4} [inst : Fintype ι] [inst_1 : Semiring M] [inst_2 : Module ℚ≥0 M] [Nonempty ι],
(Finset.univ.expect fun _i ↦ 1) = 1
theorem Fintype.expect_mul_expect E1 #
∀ {ι : Type u_1} {κ : Type u_2} {M : Type u_4} [inst : Fintype ι] [inst_1 : Fintype κ] [inst_2 : Semiring M]
[inst_3 : Module ℚ≥0 M] [IsScalarTower ℚ≥0 M M] [SMulCommClass ℚ≥0 M M] (f : ι → M) (g : κ → M),
((Finset.univ.expect fun i ↦ f i) * Finset.univ.expect fun j ↦ g j) =
Finset.univ.expect fun i ↦ Finset.univ.expect fun j ↦ f i * g j