l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem toOuterMeasure_caratheodory : p.toOuterMeasure.caratheodory = ⊤ := by
  refine' eq_top_iff.2 <| le_trans (le_sInf fun x hx => _) (le_sum_caratheodory _)
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
x : MeasurableSpace α
hx : x ∈ Set.range fun i => OuterMeasure.caratheodory (p i • dirac i)
⊢ ⊤ ≤ x

Next tactic:
have ⟨y, hy⟩ := hx
@[simp]
theorem toOuterMeasure_caratheodory : p.toOuterMeasure.caratheodory = ⊤ := by
  refine' eq_top_iff.2 <| le_trans (le_sInf fun x hx => _) (le_sum_caratheodory _)
  have ⟨y, hy⟩ := hx
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
x : MeasurableSpace α
hx : x ∈ Set.range fun i => OuterMeasure.caratheodory (p i • dirac i)
y : α
hy : (fun i => OuterMeasure.caratheodory (p i • dirac i)) y = x
⊢ ⊤ ≤ x

Next tactic:
exact
    ((le_of_eq (dirac_caratheodory y).symm).trans (le_smul_caratheodory _ _)).trans (le_of_eq hy)
@[simp]
theorem toOuterMeasure_apply_finset (s : Finset α) : p.toOuterMeasure s = ∑ x in s, p x := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s✝ t : Set α
s : Finset α
⊢ ↑(toOuterMeasure p) ↑s = ∑ x in s, p x

Next tactic:
refine' (toOuterMeasure_apply p s).trans ((tsum_eq_sum (s := s) _).trans _)
@[simp]
theorem toOuterMeasure_apply_finset (s : Finset α) : p.toOuterMeasure s = ∑ x in s, p x := by
  refine' (toOuterMeasure_apply p s).trans ((tsum_eq_sum (s := s) _).trans _)
  · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s✝ t : Set α
s : Finset α
⊢ ∀ b ∉ s, Set.indicator (↑s) (⇑p) b = 0

Next tactic:
exact fun x hx => Set.indicator_of_not_mem (Finset.mem_coe.not.2 hx) _
@[simp]
theorem toOuterMeasure_apply_finset (s : Finset α) : p.toOuterMeasure s = ∑ x in s, p x := by
  refine' (toOuterMeasure_apply p s).trans ((tsum_eq_sum (s := s) _).trans _)
  · exact fun x hx => Set.indicator_of_not_mem (Finset.mem_coe.not.2 hx) _
  · 

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s✝ t : Set α
s : Finset α
⊢ ∑ b in s, Set.indicator (↑s) (⇑p) b = ∑ x in s, p x

Next tactic:
exact Finset.sum_congr rfl fun x hx => Set.indicator_of_mem (Finset.mem_coe.2 hx) _
theorem toOuterMeasure_apply_singleton (a : α) : p.toOuterMeasure {a} = p a := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
a : α
⊢ ↑(toOuterMeasure p) {a} = p a

Next tactic:
refine' (p.toOuterMeasure_apply {a}).trans ((tsum_eq_single a fun b hb => _).trans _)
theorem toOuterMeasure_apply_singleton (a : α) : p.toOuterMeasure {a} = p a := by
  refine' (p.toOuterMeasure_apply {a}).trans ((tsum_eq_single a fun b hb => _).trans _)
  · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
a b : α
hb : b ≠ a
⊢ Set.indicator {a} (⇑p) b = 0

Next tactic:
exact ite_eq_right_iff.2 fun hb' => False.elim <| hb hb'
theorem toOuterMeasure_apply_singleton (a : α) : p.toOuterMeasure {a} = p a := by
  refine' (p.toOuterMeasure_apply {a}).trans ((tsum_eq_single a fun b hb => _).trans _)
  · exact ite_eq_right_iff.2 fun hb' => False.elim <| hb hb'
  · 

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
a : α
⊢ Set.indicator {a} (⇑p) a = p a

Next tactic:
exact ite_eq_left_iff.2 fun ha' => False.elim <| ha' rfl
theorem toOuterMeasure_apply_eq_zero_iff : p.toOuterMeasure s = 0 ↔ Disjoint p.support s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
⊢ ↑(toOuterMeasure p) s = 0 ↔ Disjoint (support p) s

Next tactic:
rw [toOuterMeasure_apply, ENNReal.tsum_eq_zero]
theorem toOuterMeasure_apply_eq_zero_iff : p.toOuterMeasure s = 0 ↔ Disjoint p.support s := by
  rw [toOuterMeasure_apply, ENNReal.tsum_eq_zero]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
⊢ (∀ (i : α), Set.indicator s (⇑p) i = 0) ↔ Disjoint (support p) s

Next tactic:
exact Function.funext_iff.symm.trans Set.indicator_eq_zero'
theorem toOuterMeasure_apply_eq_one_iff : p.toOuterMeasure s = 1 ↔ p.support ⊆ s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
⊢ ↑(toOuterMeasure p) s = 1 ↔ support p ⊆ s

Next tactic:
refine' (p.toOuterMeasure_apply s).symm ▸ ⟨fun h a hap => _, fun h => _⟩
theorem toOuterMeasure_apply_eq_one_iff : p.toOuterMeasure s = 1 ↔ p.support ⊆ s := by
  refine' (p.toOuterMeasure_apply s).symm ▸ ⟨fun h a hap => _, fun h => _⟩
  · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
h : ∑' (x : α), Set.indicator s (⇑p) x = 1
a : α
hap : a ∈ support p
⊢ a ∈ s

Next tactic:
refine' by_contra fun hs => ne_of_lt _ (h.trans p.tsum_coe.symm)
theorem toOuterMeasure_apply_eq_one_iff : p.toOuterMeasure s = 1 ↔ p.support ⊆ s := by
  refine' (p.toOuterMeasure_apply s).symm ▸ ⟨fun h a hap => _, fun h => _⟩
  · refine' by_contra fun hs => ne_of_lt _ (h.trans p.tsum_coe.symm)
    

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
h : ∑' (x : α), Set.indicator s (⇑p) x = 1
a : α
hap : a ∈ support p
hs : a ∉ s
⊢ ∑' (x : α), Set.indicator s (⇑p) x < ∑' (a : α), p a

Next tactic:
have hs' : s.indicator p a = 0 := Set.indicator_apply_eq_zero.2 fun hs' => False.elim <| hs hs'
theorem toOuterMeasure_apply_eq_one_iff : p.toOuterMeasure s = 1 ↔ p.support ⊆ s := by
  refine' (p.toOuterMeasure_apply s).symm ▸ ⟨fun h a hap => _, fun h => _⟩
  · refine' by_contra fun hs => ne_of_lt _ (h.trans p.tsum_coe.symm)
    have hs' : s.indicator p a = 0 := Set.indicator_apply_eq_zero.2 fun hs' => False.elim <| hs hs'
    

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
h : ∑' (x : α), Set.indicator s (⇑p) x = 1
a : α
hap : a ∈ support p
hs : a ∉ s
hs' : Set.indicator s (⇑p) a = 0
⊢ ∑' (x : α), Set.indicator s (⇑p) x < ∑' (a : α), p a

Next tactic:
have hsa : s.indicator p a < p a := hs'.symm ▸ (p.apply_pos_iff a).2 hap
theorem toOuterMeasure_apply_eq_one_iff : p.toOuterMeasure s = 1 ↔ p.support ⊆ s := by
  refine' (p.toOuterMeasure_apply s).symm ▸ ⟨fun h a hap => _, fun h => _⟩
  · refine' by_contra fun hs => ne_of_lt _ (h.trans p.tsum_coe.symm)
    have hs' : s.indicator p a = 0 := Set.indicator_apply_eq_zero.2 fun hs' => False.elim <| hs hs'
    have hsa : s.indicator p a < p a := hs'.symm ▸ (p.apply_pos_iff a).2 hap
    

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
h : ∑' (x : α), Set.indicator s (⇑p) x = 1
a : α
hap : a ∈ support p
hs : a ∉ s
hs' : Set.indicator s (⇑p) a = 0
hsa : Set.indicator s (⇑p) a < p a
⊢ ∑' (x : α), Set.indicator s (⇑p) x < ∑' (a : α), p a

Next tactic:
exact ENNReal.tsum_lt_tsum (p.tsum_coe_indicator_ne_top s)
      (fun x => Set.indicator_apply_le fun _ => le_rfl) hsa
theorem toOuterMeasure_apply_eq_one_iff : p.toOuterMeasure s = 1 ↔ p.support ⊆ s := by
  refine' (p.toOuterMeasure_apply s).symm ▸ ⟨fun h a hap => _, fun h => _⟩
  · refine' by_contra fun hs => ne_of_lt _ (h.trans p.tsum_coe.symm)
    have hs' : s.indicator p a = 0 := Set.indicator_apply_eq_zero.2 fun hs' => False.elim <| hs hs'
    have hsa : s.indicator p a < p a := hs'.symm ▸ (p.apply_pos_iff a).2 hap
    exact ENNReal.tsum_lt_tsum (p.tsum_coe_indicator_ne_top s)
      (fun x => Set.indicator_apply_le fun _ => le_rfl) hsa
  · 

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
h : support p ⊆ s
⊢ ∑' (x : α), Set.indicator s (⇑p) x = 1

Next tactic:
suffices : ∀ (x) (_ : x ∉ s), p x = 0
theorem toOuterMeasure_apply_eq_one_iff : p.toOuterMeasure s = 1 ↔ p.support ⊆ s := by
  refine' (p.toOuterMeasure_apply s).symm ▸ ⟨fun h a hap => _, fun h => _⟩
  · refine' by_contra fun hs => ne_of_lt _ (h.trans p.tsum_coe.symm)
    have hs' : s.indicator p a = 0 := Set.indicator_apply_eq_zero.2 fun hs' => False.elim <| hs hs'
    have hsa : s.indicator p a < p a := hs'.symm ▸ (p.apply_pos_iff a).2 hap
    exact ENNReal.tsum_lt_tsum (p.tsum_coe_indicator_ne_top s)
      (fun x => Set.indicator_apply_le fun _ => le_rfl) hsa
  · suffices : ∀ (x) (_ : x ∉ s), p x = 0
    

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
h : support p ⊆ s
this : ∀ x ∉ s, p x = 0
⊢ ∑' (x : α), Set.indicator s (⇑p) x = 1
case this α : Type u_1 β : Type u_2 γ : Type u_3 p : PMF α s t : Set α h : support p ⊆ s ⊢ ∀ x ∉ s, p x = 0

Next tactic:
exact _root_.trans (tsum_congr
      fun a => (Set.indicator_apply s p a).trans (ite_eq_left_iff.2 <| symm ∘ this a)) p.tsum_coe
theorem toOuterMeasure_apply_eq_one_iff : p.toOuterMeasure s = 1 ↔ p.support ⊆ s := by
  refine' (p.toOuterMeasure_apply s).symm ▸ ⟨fun h a hap => _, fun h => _⟩
  · refine' by_contra fun hs => ne_of_lt _ (h.trans p.tsum_coe.symm)
    have hs' : s.indicator p a = 0 := Set.indicator_apply_eq_zero.2 fun hs' => False.elim <| hs hs'
    have hsa : s.indicator p a < p a := hs'.symm ▸ (p.apply_pos_iff a).2 hap
    exact ENNReal.tsum_lt_tsum (p.tsum_coe_indicator_ne_top s)
      (fun x => Set.indicator_apply_le fun _ => le_rfl) hsa
  · suffices : ∀ (x) (_ : x ∉ s), p x = 0
    exact _root_.trans (tsum_congr
      fun a => (Set.indicator_apply s p a).trans (ite_eq_left_iff.2 <| symm ∘ this a)) p.tsum_coe
    

Proof state:
case this
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
h : support p ⊆ s
⊢ ∀ x ∉ s, p x = 0

Next tactic:
exact fun a ha => (p.apply_eq_zero_iff a).2 <| Set.not_mem_subset h ha
@[simp]
theorem toOuterMeasure_apply_inter_support :
    p.toOuterMeasure (s ∩ p.support) = p.toOuterMeasure s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : PMF α
s t : Set α
⊢ ↑(toOuterMeasure p) (s ∩ support p) = ↑(toOuterMeasure p) s

Next tactic:
simp only [toOuterMeasure_apply, PMF.support, Set.indicator_inter_support]
theorem toMeasure_apply_singleton (a : α) (h : MeasurableSet ({a} : Set α)) :
    p.toMeasure {a} = p a := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : MeasurableSpace α
p : PMF α
s t : Set α
a : α
h : MeasurableSet {a}
⊢ ↑↑(toMeasure p) {a} = p a

Next tactic:
simp [toMeasure_apply_eq_toOuterMeasure_apply _ _ h, toOuterMeasure_apply_singleton]
theorem toMeasure_apply_eq_zero_iff (hs : MeasurableSet s) :
    p.toMeasure s = 0 ↔ Disjoint p.support s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : MeasurableSpace α
p : PMF α
s t : Set α
hs : MeasurableSet s
⊢ ↑↑(toMeasure p) s = 0 ↔ Disjoint (support p) s

Next tactic:
rw [toMeasure_apply_eq_toOuterMeasure_apply p s hs, toOuterMeasure_apply_eq_zero_iff]
@[simp]
theorem toMeasure_apply_inter_support (hs : MeasurableSet s) (hp : MeasurableSet p.support) :
    p.toMeasure (s ∩ p.support) = p.toMeasure s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : MeasurableSpace α
p : PMF α
s t : Set α
hs : MeasurableSet s
hp : MeasurableSet (support p)
⊢ ↑↑(toMeasure p) (s ∩ support p) = ↑↑(toMeasure p) s

Next tactic:
simp [p.toMeasure_apply_eq_toOuterMeasure_apply s hs,
    p.toMeasure_apply_eq_toOuterMeasure_apply _ (hs.inter hp)]
@[simp]
theorem restrict_toMeasure_support [MeasurableSpace α] [MeasurableSingletonClass α]  (p : PMF α) :
    Measure.restrict (toMeasure p) (support p) = toMeasure p := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝² : MeasurableSpace α
p✝ : PMF α
s t : Set α
inst✝¹ : MeasurableSpace α
inst✝ : MeasurableSingletonClass α
p : PMF α
⊢ Measure.restrict (toMeasure p) (support p) = toMeasure p

Next tactic:
ext s hs
@[simp]
theorem restrict_toMeasure_support [MeasurableSpace α] [MeasurableSingletonClass α]  (p : PMF α) :
    Measure.restrict (toMeasure p) (support p) = toMeasure p := by
  ext s hs
  

Proof state:
case h
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝² : MeasurableSpace α
p✝ : PMF α
s✝ t : Set α
inst✝¹ : MeasurableSpace α
inst✝ : MeasurableSingletonClass α
p : PMF α
s : Set α
hs : MeasurableSet s
⊢ ↑↑(Measure.restrict (toMeasure p) (support p)) s = ↑↑(toMeasure p) s

Next tactic:
apply (MeasureTheory.Measure.restrict_apply hs).trans
@[simp]
theorem restrict_toMeasure_support [MeasurableSpace α] [MeasurableSingletonClass α]  (p : PMF α) :
    Measure.restrict (toMeasure p) (support p) = toMeasure p := by
  ext s hs
  apply (MeasureTheory.Measure.restrict_apply hs).trans
  

Proof state:
case h
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝² : MeasurableSpace α
p✝ : PMF α
s✝ t : Set α
inst✝¹ : MeasurableSpace α
inst✝ : MeasurableSingletonClass α
p : PMF α
s : Set α
hs : MeasurableSet s
⊢ ↑↑(toMeasure p) (s ∩ support p) = ↑↑(toMeasure p) s

Next tactic:
apply toMeasure_apply_inter_support p s hs p.support_countable.measurableSet
theorem toMeasure_mono {s t : Set α} (hs : MeasurableSet s) (ht : MeasurableSet t)
    (h : s ∩ p.support ⊆ t) : p.toMeasure s ≤ p.toMeasure t := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : MeasurableSpace α
p : PMF α
s✝ t✝ s t : Set α
hs : MeasurableSet s
ht : MeasurableSet t
h : s ∩ support p ⊆ t
⊢ ↑↑(toMeasure p) s ≤ ↑↑(toMeasure p) t

Next tactic:
simpa only [p.toMeasure_apply_eq_toOuterMeasure_apply, hs, ht] using toOuterMeasure_mono p h
theorem toMeasure_apply_eq_of_inter_support_eq {s t : Set α} (hs : MeasurableSet s)
    (ht : MeasurableSet t) (h : s ∩ p.support = t ∩ p.support) : p.toMeasure s = p.toMeasure t := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : MeasurableSpace α
p : PMF α
s✝ t✝ s t : Set α
hs : MeasurableSet s
ht : MeasurableSet t
h : s ∩ support p = t ∩ support p
⊢ ↑↑(toMeasure p) s = ↑↑(toMeasure p) t

Next tactic:
simpa only [p.toMeasure_apply_eq_toOuterMeasure_apply, hs, ht] using
    toOuterMeasure_apply_eq_of_inter_support_eq p h
theorem toMeasure_injective : (toMeasure : PMF α → Measure α).Injective := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : MeasurableSpace α
p : PMF α
s t : Set α
inst✝ : MeasurableSingletonClass α
⊢ Function.Injective toMeasure

Next tactic:
intro p q h
theorem toMeasure_injective : (toMeasure : PMF α → Measure α).Injective := by
  intro p q h
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : MeasurableSpace α
p✝ : PMF α
s t : Set α
inst✝ : MeasurableSingletonClass α
p q : PMF α
h : toMeasure p = toMeasure q
⊢ p = q

Next tactic:
ext x
theorem toMeasure_injective : (toMeasure : PMF α → Measure α).Injective := by
  intro p q h
  ext x
  

Proof state:
case h
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : MeasurableSpace α
p✝ : PMF α
s t : Set α
inst✝ : MeasurableSingletonClass α
p q : PMF α
h : toMeasure p = toMeasure q
x : α
⊢ p x = q x

Next tactic:
rw [← p.toMeasure_apply_singleton x <| measurableSet_singleton x,
    ← q.toMeasure_apply_singleton x <| measurableSet_singleton x, h]
@[simp]
theorem toPMF_toMeasure : μ.toPMF.toMeasure = μ :=
  Measure.ext fun s hs => by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝³ : Countable α
inst✝² : MeasurableSpace α
inst✝¹ : MeasurableSingletonClass α
μ : Measure α
inst✝ : IsProbabilityMeasure μ
s : Set α
hs : MeasurableSet s
⊢ ↑↑(toMeasure (toPMF μ)) s = ↑↑μ s

Next tactic:
rw [μ.toPMF.toMeasure_apply s hs, ← μ.tsum_indicator_apply_singleton s hs]
@[simp]
theorem toPMF_toMeasure : μ.toPMF.toMeasure = μ :=
  Measure.ext fun s hs => by
    rw [μ.toPMF.toMeasure_apply s hs, ← μ.tsum_indicator_apply_singleton s hs]
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝³ : Countable α
inst✝² : MeasurableSpace α
inst✝¹ : MeasurableSingletonClass α
μ : Measure α
inst✝ : IsProbabilityMeasure μ
s : Set α
hs : MeasurableSet s
⊢ ∑' (x : α), Set.indicator s (⇑(toPMF μ)) x = ∑' (x : α), Set.indicator s (fun x => ↑↑μ {x}) x

Next tactic:
rfl
/-- The measure associated to a `PMF` by `toMeasure` is a probability measure. -/
instance toMeasure.isProbabilityMeasure [MeasurableSpace α] (p : PMF α) :
    IsProbabilityMeasure p.toMeasure :=
  ⟨by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : MeasurableSpace α
p : PMF α
⊢ ↑↑(toMeasure p) Set.univ = 1

Next tactic:
simpa only [MeasurableSet.univ, toMeasure_apply_eq_toOuterMeasure_apply, Set.indicator_univ,
      toOuterMeasure_apply, ENNReal.coe_eq_one] using tsum_coe p
@[simp]
theorem toMeasure_toPMF : p.toMeasure.toPMF = p :=
  PMF.ext fun x => by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝³ : Countable α
inst✝² : MeasurableSpace α
inst✝¹ : MeasurableSingletonClass α
p : PMF α
μ : Measure α
inst✝ : IsProbabilityMeasure μ
x : α
⊢ (Measure.toPMF (toMeasure p)) x = p x

Next tactic:
rw [← p.toMeasure_apply_singleton x (measurableSet_singleton x), p.toMeasure.toPMF_apply]
theorem toMeasure_eq_iff_eq_toPMF (μ : Measure α) [IsProbabilityMeasure μ] :
    p.toMeasure = μ ↔ p = μ.toPMF := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝⁴ : Countable α
inst✝³ : MeasurableSpace α
inst✝² : MeasurableSingletonClass α
p : PMF α
μ✝ : Measure α
inst✝¹ : IsProbabilityMeasure μ✝
μ : Measure α
inst✝ : IsProbabilityMeasure μ
⊢ toMeasure p = μ ↔ p = Measure.toPMF μ

Next tactic:
rw [← toMeasure_inj, Measure.toPMF_toMeasure]
theorem toPMF_eq_iff_toMeasure_eq (μ : Measure α) [IsProbabilityMeasure μ] :
    μ.toPMF = p ↔ μ = p.toMeasure := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝⁴ : Countable α
inst✝³ : MeasurableSpace α
inst✝² : MeasurableSingletonClass α
p : PMF α
μ✝ : Measure α
inst✝¹ : IsProbabilityMeasure μ✝
μ : Measure α
inst✝ : IsProbabilityMeasure μ
⊢ Measure.toPMF μ = p ↔ μ = toMeasure p

Next tactic:
rw [← toMeasure_inj, Measure.toPMF_toMeasure]
/-- If a function is monotone and is bounded on a set `s`, then it admits a monotone extension to
the whole space. -/
theorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow (f '' s))
    (hu : BddAbove (f '' s)) : ∃ g : α → β, Monotone g ∧ EqOn f g s := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : ConditionallyCompleteLinearOrder β
f : α → β
s : Set α
a b : α
h : MonotoneOn f s
hl : BddBelow (f '' s)
hu : BddAbove (f '' s)
⊢ ∃ g, Monotone g ∧ EqOn f g s

Next tactic:
classical
    /- The extension is defined by `f x = f a` for `x ≤ a`, and `f x` is the supremum of the values
      of `f` to the left of `x` for `x ≥ a`. -/
    rcases hl with ⟨a, ha⟩
    have hu' : ∀ x, BddAbove (f '' (Iic x ∩ s)) := fun x =>
      hu.mono (image_subset _ (inter_subset_right _ _))
    let g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s))
    have hgs : EqOn f g s := by
      intro x hx
      simp only []
      have : IsGreatest (Iic x ∩ s) x := ⟨⟨right_mem_Iic, hx⟩, fun y hy => hy.1⟩
      rw [if_neg this.nonempty.not_disjoint,
        ((h.mono <| inter_subset_right _ _).map_isGreatest this).csSup_eq]
    refine' ⟨g, fun x y hxy => _, hgs⟩
    by_cases hx : Disjoint (Iic x) s <;> by_cases hy : Disjoint (Iic y) s <;>
      simp only [if_pos, if_neg, not_false_iff, *, refl]
    · rcases not_disjoint_iff_nonempty_inter.1 hy with ⟨z, hz⟩
      exact le_csSup_of_le (hu' _) (mem_image_of_mem _ hz) (ha <| mem_image_of_mem _ hz.2)
    · exact (hx <| hy.mono_left <| Iic_subset_Iic.2 hxy).elim
    · rw [not_disjoint_iff_nonempty_inter] at hx hy
      refine' csSup_le_csSup (hu' _) (hx.image _) (image_subset _ _)
      exact inter_subset_inter_left _ (Iic_subset_Iic.2 hxy)
/-- If a function is monotone and is bounded on a set `s`, then it admits a monotone extension to
the whole space. -/
theorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow (f '' s))
    (hu : BddAbove (f '' s)) : ∃ g : α → β, Monotone g ∧ EqOn f g s := by
  classical
    /- The extension is defined by `f x = f a` for `x ≤ a`, and `f x` is the supremum of the values
      of `f` to the left of `x` for `x ≥ a`. -/
    

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : ConditionallyCompleteLinearOrder β
f : α → β
s : Set α
a b : α
h : MonotoneOn f s
hl : BddBelow (f '' s)
hu : BddAbove (f '' s)
⊢ ∃ g, Monotone g ∧ EqOn f g s

Next tactic:
rcases hl with ⟨a, ha⟩
/-- If a function is monotone and is bounded on a set `s`, then it admits a monotone extension to
the whole space. -/
theorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow (f '' s))
    (hu : BddAbove (f '' s)) : ∃ g : α → β, Monotone g ∧ EqOn f g s := by
  classical
    /- The extension is defined by `f x = f a` for `x ≤ a`, and `f x` is the supremum of the values
      of `f` to the left of `x` for `x ≥ a`. -/
    rcases hl with ⟨a, ha⟩
    

Proof state:
case intro
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : ConditionallyCompleteLinearOrder β
f : α → β
s : Set α
a✝ b : α
h : MonotoneOn f s
hu : BddAbove (f '' s)
a : β
ha : a ∈ lowerBounds (f '' s)
⊢ ∃ g, Monotone g ∧ EqOn f g s

Next tactic:
have hu' : ∀ x, BddAbove (f '' (Iic x ∩ s)) := fun x =>
      hu.mono (image_subset _ (inter_subset_right _ _))
/-- If a function is monotone and is bounded on a set `s`, then it admits a monotone extension to
the whole space. -/
theorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow (f '' s))
    (hu : BddAbove (f '' s)) : ∃ g : α → β, Monotone g ∧ EqOn f g s := by
  classical
    /- The extension is defined by `f x = f a` for `x ≤ a`, and `f x` is the supremum of the values
      of `f` to the left of `x` for `x ≥ a`. -/
    rcases hl with ⟨a, ha⟩
    have hu' : ∀ x, BddAbove (f '' (Iic x ∩ s)) := fun x =>
      hu.mono (image_subset _ (inter_subset_right _ _))
    

Proof state:
case intro
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : ConditionallyCompleteLinearOrder β
f : α → β
s : Set α
a✝ b : α
h : MonotoneOn f s
hu : BddAbove (f '' s)
a : β
ha : a ∈ lowerBounds (f '' s)
hu' : ∀ (x : α), BddAbove (f '' (Iic x ∩ s))
⊢ ∃ g, Monotone g ∧ EqOn f g s

Next tactic:
let g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s))
/-- If a function is monotone and is bounded on a set `s`, then it admits a monotone extension to
the whole space. -/
theorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow (f '' s))
    (hu : BddAbove (f '' s)) : ∃ g : α → β, Monotone g ∧ EqOn f g s := by
  classical
    /- The extension is defined by `f x = f a` for `x ≤ a`, and `f x` is the supremum of the values
      of `f` to the left of `x` for `x ≥ a`. -/
    rcases hl with ⟨a, ha⟩
    have hu' : ∀ x, BddAbove (f '' (Iic x ∩ s)) := fun x =>
      hu.mono (image_subset _ (inter_subset_right _ _))
    let g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s))
    

Proof state:
case intro
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : ConditionallyCompleteLinearOrder β
f : α → β
s : Set α
a✝ b : α
h : MonotoneOn f s
hu : BddAbove (f '' s)
a : β
ha : a ∈ lowerBounds (f '' s)
hu' : ∀ (x : α), BddAbove (f '' (Iic x ∩ s))
g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s))
⊢ ∃ g, Monotone g ∧ EqOn f g s

Next tactic:
have hgs : EqOn f g s := by
      intro x hx
      simp only []
      have : IsGreatest (Iic x ∩ s) x := ⟨⟨right_mem_Iic, hx⟩, fun y hy => hy.1⟩
      rw [if_neg this.nonempty.not_disjoint,
        ((h.mono <| inter_subset_right _ _).map_isGreatest this).csSup_eq]
/-- If a function is monotone and is bounded on a set `s`, then it admits a monotone extension to
the whole space. -/
theorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow (f '' s))
    (hu : BddAbove (f '' s)) : ∃ g : α → β, Monotone g ∧ EqOn f g s := by
  classical
    /- The extension is defined by `f x = f a` for `x ≤ a`, and `f x` is the supremum of the values
      of `f` to the left of `x` for `x ≥ a`. -/
    rcases hl with ⟨a, ha⟩
    have hu' : ∀ x, BddAbove (f '' (Iic x ∩ s)) := fun x =>
      hu.mono (image_subset _ (inter_subset_right _ _))
    let g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s))
    have hgs : EqOn f g s := by
      

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : ConditionallyCompleteLinearOrder β
f : α → β
s : Set α
a✝ b : α
h : MonotoneOn f s
hu : BddAbove (f '' s)
a : β
ha : a ∈ lowerBounds (f '' s)
hu' : ∀ (x : α), BddAbove (f '' (Iic x ∩ s))
g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s))
⊢ EqOn f g s

Next tactic:
intro x hx