File: Mathlib/Probability/ProbabilityMassFunction/Constructions.lean

full_name: PMF.map
code: /-- The functorial action of a function on a `PMF`. -/
def map (f : α → β) (p : PMF α) : PMF β 
goal: PMF β

full_name: PMF.monad_map_eq_map
code: theorem monad_map_eq_map {α β : Type u} (f : α → β) (p : PMF α) : f <$> p = p.map f 
goal: f <$> p = PMF.map f p

full_name: PMF.map_apply
code: @[simp]
theorem map_apply : (map f p) b = ∑' a, if b = f a then p a else 0 
goal: (PMF.map f p) b = ∑' (a : α), if b = f a then p a else 0

full_name: PMF.support_map
code: @[simp]
theorem support_map : (map f p).support = f '' p.support 
goal: (PMF.map f p).support = f '' p.support

full_name: PMF.mem_support_map_iff
code: theorem mem_support_map_iff : b ∈ (map f p).support ↔ ∃ a ∈ p.support, f a = b 
goal: b ∈ (PMF.map f p).support ↔ ∃ a ∈ p.support, f a = b

full_name: PMF.bind_pure_comp
code: theorem bind_pure_comp : bind p (pure ∘ f) = map f p 
goal: p.bind (PMF.pure ∘ f) = PMF.map f p

full_name: PMF.map_id
code: theorem map_id : map id p = p 
goal: PMF.map id p = p

full_name: PMF.map_comp
code: theorem map_comp (g : β → γ) : (p.map f).map g = p.map (g ∘ f) 
goal: PMF.map g (PMF.map f p) = PMF.map (g ∘ f) p

full_name: PMF.pure_map
code: theorem pure_map (a : α) : (pure a).map f = pure (f a) 
goal: PMF.map f (PMF.pure a) = PMF.pure (f a)

full_name: PMF.map_bind
code: theorem map_bind (q : α → PMF β) (f : β → γ) : (p.bind q).map f = p.bind fun a => (q a).map f 
goal: PMF.map f (p.bind q) = p.bind fun a => PMF.map f (q a)

full_name: PMF.bind_map
code: @[simp]
theorem bind_map (p : PMF α) (f : α → β) (q : β → PMF γ) : (p.map f).bind q = p.bind (q ∘ f) 
goal: (PMF.map f p).bind q = p.bind (q ∘ f)

full_name: PMF.map_const
code: @[simp]
theorem map_const : p.map (Function.const α b) = pure b 
goal: PMF.map (Function.const α b) p = PMF.pure b

full_name: PMF.toOuterMeasure_map_apply
code: @[simp]
theorem toOuterMeasure_map_apply : (p.map f).toOuterMeasure s = p.toOuterMeasure (f ⁻¹' s) 
goal: (PMF.map f p).toOuterMeasure s = p.toOuterMeasure (f ⁻¹' s)

full_name: PMF.toMeasure_map_apply
code: @[simp]
theorem toMeasure_map_apply [MeasurableSpace α] [MeasurableSpace β] (hf : Measurable f)
    (hs : MeasurableSet s) : (p.map f).toMeasure s = p.toMeasure (f ⁻¹' s) 
goal: (PMF.map f p).toMeasure s = p.toMeasure (f ⁻¹' s)

full_name: PMF.seq
code: /-- The monadic sequencing operation for `PMF`. -/
def seq (q : PMF (α → β)) (p : PMF α) : PMF β 
goal: PMF β

full_name: PMF.monad_seq_eq_seq
code: theorem monad_seq_eq_seq {α β : Type u} (q : PMF (α → β)) (p : PMF α) : q <*> p = q.seq p 
goal: (Seq.seq q fun x => p) = q.seq p

full_name: PMF.seq_apply
code: @[simp]
theorem seq_apply : (seq q p) b = ∑' (f : α → β) (a : α), if b = f a then q f * p a else 0 
goal: (q.seq p) b = ∑' (f : α → β) (a : α), if b = f a then q f * p a else 0

full_name: PMF.support_seq
code: @[simp]
theorem support_seq : (seq q p).support = ⋃ f ∈ q.support, f '' p.support 
goal: (q.seq p).support = ⋃ f ∈ q.support, f '' p.support

full_name: PMF.mem_support_seq_iff
code: theorem mem_support_seq_iff : b ∈ (seq q p).support ↔ ∃ f ∈ q.support, b ∈ f '' p.support 
goal: b ∈ (q.seq p).support ↔ ∃ f ∈ q.support, b ∈ f '' p.support

full_name: PMF.instLawfulFunctor
code: instance : LawfulFunctor PMF 
goal: LawfulFunctor PMF

full_name: PMF.instLawfulMonad
code: instance : LawfulMonad PMF 
goal: LawfulMonad PMF

full_name: PMF.ofFinset
code: /-- Given a finset `s` and a function `f : α → ℝ≥0∞` with sum `1` on `s`,
  such that `f a = 0` for `a ∉ s`, we get a `PMF`. -/
def ofFinset (f : α → ℝ≥0∞) (s : Finset α) (h : ∑ a ∈ s, f a = 1)
    (h' : ∀ (a) (_ : a ∉ s), f a = 0) : PMF α 
goal: PMF α

full_name: PMF.ofFinset_apply
code: @[simp]
theorem ofFinset_apply (a : α) : ofFinset f s h h' a = f a 
goal: (PMF.ofFinset f s h h') a = f a

full_name: PMF.support_ofFinset
code: @[simp]
theorem support_ofFinset : (ofFinset f s h h').support = ↑s ∩ Function.support f 
goal: (PMF.ofFinset f s h h').support = ↑s ∩ Function.support f

full_name: PMF.mem_support_ofFinset_iff
code: theorem mem_support_ofFinset_iff (a : α) : a ∈ (ofFinset f s h h').support ↔ a ∈ s ∧ f a ≠ 0 
goal: a ∈ (PMF.ofFinset f s h h').support ↔ a ∈ s ∧ f a ≠ 0

full_name: PMF.ofFinset_apply_of_not_mem
code: theorem ofFinset_apply_of_not_mem {a : α} (ha : a ∉ s) : ofFinset f s h h' a = 0 
goal: (PMF.ofFinset f s h h') a = 0

full_name: PMF.toOuterMeasure_ofFinset_apply
code: @[simp]
theorem toOuterMeasure_ofFinset_apply :
    (ofFinset f s h h').toOuterMeasure t = ∑' x, t.indicator f x 
goal: (PMF.ofFinset f s h h').toOuterMeasure t = ∑' (x : α), t.indicator f x

full_name: PMF.toMeasure_ofFinset_apply
code: @[simp]
theorem toMeasure_ofFinset_apply [MeasurableSpace α] (ht : MeasurableSet t) :
    (ofFinset f s h h').toMeasure t = ∑' x, t.indicator f x 
goal: (PMF.ofFinset f s h h').toMeasure t = ∑' (x : α), t.indicator f x

full_name: PMF.ofFintype
code: /-- Given a finite type `α` and a function `f : α → ℝ≥0∞` with sum 1, we get a `PMF`. -/
def ofFintype [Fintype α] (f : α → ℝ≥0∞) (h : ∑ a, f a = 1) : PMF α 
goal: PMF α

full_name: PMF.ofFintype_apply
code: @[simp]
theorem ofFintype_apply (a : α) : ofFintype f h a = f a 
goal: (PMF.ofFintype f h) a = f a

full_name: PMF.support_ofFintype
code: @[simp]
theorem support_ofFintype : (ofFintype f h).support = Function.support f 
goal: (PMF.ofFintype f h).support = Function.support f

full_name: PMF.mem_support_ofFintype_iff
code: theorem mem_support_ofFintype_iff (a : α) : a ∈ (ofFintype f h).support ↔ f a ≠ 0 
goal: a ∈ (PMF.ofFintype f h).support ↔ f a ≠ 0

full_name: PMF.toOuterMeasure_ofFintype_apply
code: @[simp high]
theorem toOuterMeasure_ofFintype_apply : (ofFintype f h).toOuterMeasure s = ∑' x, s.indicator f x 
goal: (PMF.ofFintype f h).toOuterMeasure s = ∑' (x : α), s.indicator f x

full_name: PMF.toMeasure_ofFintype_apply
code: @[simp]
theorem toMeasure_ofFintype_apply [MeasurableSpace α] (hs : MeasurableSet s) :
    (ofFintype f h).toMeasure s = ∑' x, s.indicator f x 
goal: (PMF.ofFintype f h).toMeasure s = ∑' (x : α), s.indicator f x

full_name: PMF.normalize
code: /-- Given an `f` with non-zero and non-infinite sum, get a `PMF` by normalizing `f` by its `tsum`.
-/
def normalize (f : α → ℝ≥0∞) (hf0 : tsum f ≠ 0) (hf : tsum f ≠ ∞) : PMF α 
goal: PMF α

full_name: PMF.normalize_apply
code: @[simp]
theorem normalize_apply (a : α) : (normalize f hf0 hf) a = f a * (∑' x, f x)⁻¹ 
goal: (PMF.normalize f hf0 hf) a = f a * (∑' (x : α), f x)⁻¹

full_name: PMF.support_normalize
code: @[simp]
theorem support_normalize : (normalize f hf0 hf).support = Function.support f 
goal: (PMF.normalize f hf0 hf).support = Function.support f

full_name: PMF.mem_support_normalize_iff
code: theorem mem_support_normalize_iff (a : α) : a ∈ (normalize f hf0 hf).support ↔ f a ≠ 0 
goal: a ∈ (PMF.normalize f hf0 hf).support ↔ f a ≠ 0

full_name: PMF.filter
code: /-- Create new `PMF` by filtering on a set with non-zero measure and normalizing. -/
def filter (p : PMF α) (s : Set α) (h : ∃ a ∈ s, a ∈ p.support) : PMF α 
goal: PMF α

full_name: PMF.filter_apply
code: @[simp]
theorem filter_apply (a : α) :
    (p.filter s h) a = s.indicator p a * (∑' a', (s.indicator p) a')⁻¹ 
goal: (p.filter s h) a = s.indicator (⇑p) a * (∑' (a' : α), s.indicator (⇑p) a')⁻¹

full_name: PMF.filter_apply_eq_zero_of_not_mem
code: theorem filter_apply_eq_zero_of_not_mem {a : α} (ha : a ∉ s) : (p.filter s h) a = 0 
goal: (p.filter s h) a = 0

full_name: PMF.mem_support_filter_iff
code: theorem mem_support_filter_iff {a : α} : a ∈ (p.filter s h).support ↔ a ∈ s ∧ a ∈ p.support 
goal: a ∈ (p.filter s h).support ↔ a ∈ s ∧ a ∈ p.support

full_name: PMF.support_filter
code: @[simp]
theorem support_filter : (p.filter s h).support = s ∩ p.support 
goal: (p.filter s h).support = s ∩ p.support

full_name: PMF.filter_apply_eq_zero_iff
code: theorem filter_apply_eq_zero_iff (a : α) : (p.filter s h) a = 0 ↔ a ∉ s ∨ a ∉ p.support 
goal: (p.filter s h) a = 0 ↔ a ∉ s ∨ a ∉ p.support

full_name: PMF.filter_apply_ne_zero_iff
code: theorem filter_apply_ne_zero_iff (a : α) : (p.filter s h) a ≠ 0 ↔ a ∈ s ∧ a ∈ p.support 
goal: (p.filter s h) a ≠ 0 ↔ a ∈ s ∧ a ∈ p.support

full_name: PMF.bernoulli
code: /-- A `PMF` which assigns probability `p` to `true` and `1 - p` to `false`. -/
def bernoulli (p : ℝ≥0∞) (h : p ≤ 1) : PMF Bool 
goal: PMF Bool

full_name: PMF.bernoulli_apply
code: @[simp]
theorem bernoulli_apply : bernoulli p h b = cond b p (1 - p) 
goal: (PMF.bernoulli p h) b = bif b then p else 1 - p

full_name: PMF.support_bernoulli
code: @[simp]
theorem support_bernoulli : (bernoulli p h).support = { b | cond b (p ≠ 0) (p ≠ 1) } 
goal: (PMF.bernoulli p h).support = {b | bif b then p ≠ 0 else p ≠ 1}

full_name: PMF.mem_support_bernoulli_iff
code: theorem mem_support_bernoulli_iff : b ∈ (bernoulli p h).support ↔ cond b (p ≠ 0) (p ≠ 1) 
goal: b ∈ (PMF.bernoulli p h).support ↔ bif b then p ≠ 0 else p ≠ 1