l3lab/ntp-mathlib huggingface dataset:
/-- Calculate the integral of `(g ∘ f)`, where `g : β → ℝ≥0∞` and `f : α →ₛ β`.  -/
theorem map_lintegral (g : β → ℝ≥0∞) (f : α →ₛ β) :
    (f.map g).lintegral μ = ∑ x in f.range, g x * μ (f ⁻¹' {x}) := by
  simp only [lintegral, range_map]
  refine' Finset.sum_image' _ fun b hb => _
  rcases mem_range.1 hb with ⟨a, rfl⟩
  

Proof state:
case intro
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
g : β → ℝ≥0∞
f : α →ₛ β
a : α
hb : ↑f a ∈ SimpleFunc.range f
⊢ g (↑f a) * ↑↑μ (↑(map g f) ⁻¹' {g (↑f a)}) =
    ∑ x in Finset.filter (fun c' => g c' = g (↑f a)) (SimpleFunc.range f), g x * ↑↑μ (↑f ⁻¹' {x})

Next tactic:
rw [map_preimage_singleton, ← f.sum_measure_preimage_singleton, Finset.mul_sum]
/-- Calculate the integral of `(g ∘ f)`, where `g : β → ℝ≥0∞` and `f : α →ₛ β`.  -/
theorem map_lintegral (g : β → ℝ≥0∞) (f : α →ₛ β) :
    (f.map g).lintegral μ = ∑ x in f.range, g x * μ (f ⁻¹' {x}) := by
  simp only [lintegral, range_map]
  refine' Finset.sum_image' _ fun b hb => _
  rcases mem_range.1 hb with ⟨a, rfl⟩
  rw [map_preimage_singleton, ← f.sum_measure_preimage_singleton, Finset.mul_sum]
  

Proof state:
case intro
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
g : β → ℝ≥0∞
f : α →ₛ β
a : α
hb : ↑f a ∈ SimpleFunc.range f
⊢ ∑ x in Finset.filter (fun b => g b = g (↑f a)) (SimpleFunc.range f), g (↑f a) * ↑↑μ (↑f ⁻¹' {x}) =
    ∑ x in Finset.filter (fun c' => g c' = g (↑f a)) (SimpleFunc.range f), g x * ↑↑μ (↑f ⁻¹' {x})

Next tactic:
refine' Finset.sum_congr _ _
/-- Calculate the integral of `(g ∘ f)`, where `g : β → ℝ≥0∞` and `f : α →ₛ β`.  -/
theorem map_lintegral (g : β → ℝ≥0∞) (f : α →ₛ β) :
    (f.map g).lintegral μ = ∑ x in f.range, g x * μ (f ⁻¹' {x}) := by
  simp only [lintegral, range_map]
  refine' Finset.sum_image' _ fun b hb => _
  rcases mem_range.1 hb with ⟨a, rfl⟩
  rw [map_preimage_singleton, ← f.sum_measure_preimage_singleton, Finset.mul_sum]
  refine' Finset.sum_congr _ _
  · 

Proof state:
case intro.refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
g : β → ℝ≥0∞
f : α →ₛ β
a : α
hb : ↑f a ∈ SimpleFunc.range f
⊢ Finset.filter (fun b => g b = g (↑f a)) (SimpleFunc.range f) =
    Finset.filter (fun c' => g c' = g (↑f a)) (SimpleFunc.range f)

Next tactic:
congr
/-- Calculate the integral of `(g ∘ f)`, where `g : β → ℝ≥0∞` and `f : α →ₛ β`.  -/
theorem map_lintegral (g : β → ℝ≥0∞) (f : α →ₛ β) :
    (f.map g).lintegral μ = ∑ x in f.range, g x * μ (f ⁻¹' {x}) := by
  simp only [lintegral, range_map]
  refine' Finset.sum_image' _ fun b hb => _
  rcases mem_range.1 hb with ⟨a, rfl⟩
  rw [map_preimage_singleton, ← f.sum_measure_preimage_singleton, Finset.mul_sum]
  refine' Finset.sum_congr _ _
  · congr
  · 

Proof state:
case intro.refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
g : β → ℝ≥0∞
f : α →ₛ β
a : α
hb : ↑f a ∈ SimpleFunc.range f
⊢ ∀ x ∈ Finset.filter (fun c' => g c' = g (↑f a)) (SimpleFunc.range f),
    g (↑f a) * ↑↑μ (↑f ⁻¹' {x}) = g x * ↑↑μ (↑f ⁻¹' {x})

Next tactic:
intro x
/-- Calculate the integral of `(g ∘ f)`, where `g : β → ℝ≥0∞` and `f : α →ₛ β`.  -/
theorem map_lintegral (g : β → ℝ≥0∞) (f : α →ₛ β) :
    (f.map g).lintegral μ = ∑ x in f.range, g x * μ (f ⁻¹' {x}) := by
  simp only [lintegral, range_map]
  refine' Finset.sum_image' _ fun b hb => _
  rcases mem_range.1 hb with ⟨a, rfl⟩
  rw [map_preimage_singleton, ← f.sum_measure_preimage_singleton, Finset.mul_sum]
  refine' Finset.sum_congr _ _
  · congr
  · intro x
    

Proof state:
case intro.refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
g : β → ℝ≥0∞
f : α →ₛ β
a : α
hb : ↑f a ∈ SimpleFunc.range f
x : β
⊢ x ∈ Finset.filter (fun c' => g c' = g (↑f a)) (SimpleFunc.range f) →
    g (↑f a) * ↑↑μ (↑f ⁻¹' {x}) = g x * ↑↑μ (↑f ⁻¹' {x})

Next tactic:
simp only [Finset.mem_filter]
/-- Calculate the integral of `(g ∘ f)`, where `g : β → ℝ≥0∞` and `f : α →ₛ β`.  -/
theorem map_lintegral (g : β → ℝ≥0∞) (f : α →ₛ β) :
    (f.map g).lintegral μ = ∑ x in f.range, g x * μ (f ⁻¹' {x}) := by
  simp only [lintegral, range_map]
  refine' Finset.sum_image' _ fun b hb => _
  rcases mem_range.1 hb with ⟨a, rfl⟩
  rw [map_preimage_singleton, ← f.sum_measure_preimage_singleton, Finset.mul_sum]
  refine' Finset.sum_congr _ _
  · congr
  · intro x
    simp only [Finset.mem_filter]
    

Proof state:
case intro.refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
g : β → ℝ≥0∞
f : α →ₛ β
a : α
hb : ↑f a ∈ SimpleFunc.range f
x : β
⊢ x ∈ SimpleFunc.range f ∧ g x = g (↑f a) → g (↑f a) * ↑↑μ (↑f ⁻¹' {x}) = g x * ↑↑μ (↑f ⁻¹' {x})

Next tactic:
rintro ⟨_, h⟩
/-- Calculate the integral of `(g ∘ f)`, where `g : β → ℝ≥0∞` and `f : α →ₛ β`.  -/
theorem map_lintegral (g : β → ℝ≥0∞) (f : α →ₛ β) :
    (f.map g).lintegral μ = ∑ x in f.range, g x * μ (f ⁻¹' {x}) := by
  simp only [lintegral, range_map]
  refine' Finset.sum_image' _ fun b hb => _
  rcases mem_range.1 hb with ⟨a, rfl⟩
  rw [map_preimage_singleton, ← f.sum_measure_preimage_singleton, Finset.mul_sum]
  refine' Finset.sum_congr _ _
  · congr
  · intro x
    simp only [Finset.mem_filter]
    rintro ⟨_, h⟩
    

Proof state:
case intro.refine'_2.intro
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
g : β → ℝ≥0∞
f : α →ₛ β
a : α
hb : ↑f a ∈ SimpleFunc.range f
x : β
left✝ : x ∈ SimpleFunc.range f
h : g x = g (↑f a)
⊢ g (↑f a) * ↑↑μ (↑f ⁻¹' {x}) = g x * ↑↑μ (↑f ⁻¹' {x})

Next tactic:
rw [h]
theorem add_lintegral (f g : α →ₛ ℝ≥0∞) : (f + g).lintegral μ = f.lintegral μ + g.lintegral μ :=
  calc
    (f + g).lintegral μ =
        ∑ x in (pair f g).range, (x.1 * μ (pair f g ⁻¹' {x}) + x.2 * μ (pair f g ⁻¹' {x})) :=
      by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
⊢ lintegral (f + g) μ =
    ∑ x in SimpleFunc.range (pair f g), (x.1 * ↑↑μ (↑(pair f g) ⁻¹' {x}) + x.2 * ↑↑μ (↑(pair f g) ⁻¹' {x}))

Next tactic:
rw [add_eq_map₂, map_lintegral]
theorem add_lintegral (f g : α →ₛ ℝ≥0∞) : (f + g).lintegral μ = f.lintegral μ + g.lintegral μ :=
  calc
    (f + g).lintegral μ =
        ∑ x in (pair f g).range, (x.1 * μ (pair f g ⁻¹' {x}) + x.2 * μ (pair f g ⁻¹' {x})) :=
      by rw [add_eq_map₂, map_lintegral]; 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
⊢ ∑ x in SimpleFunc.range (pair f g), (x.1 + x.2) * ↑↑μ (↑(pair f g) ⁻¹' {x}) =
    ∑ x in SimpleFunc.range (pair f g), (x.1 * ↑↑μ (↑(pair f g) ⁻¹' {x}) + x.2 * ↑↑μ (↑(pair f g) ⁻¹' {x}))

Next tactic:
exact Finset.sum_congr rfl fun a _ => add_mul _ _ _
theorem add_lintegral (f g : α →ₛ ℝ≥0∞) : (f + g).lintegral μ = f.lintegral μ + g.lintegral μ :=
  calc
    (f + g).lintegral μ =
        ∑ x in (pair f g).range, (x.1 * μ (pair f g ⁻¹' {x}) + x.2 * μ (pair f g ⁻¹' {x})) :=
      by rw [add_eq_map₂, map_lintegral]; exact Finset.sum_congr rfl fun a _ => add_mul _ _ _
    _ = (∑ x in (pair f g).range, x.1 * μ (pair f g ⁻¹' {x})) +
          ∑ x in (pair f g).range, x.2 * μ (pair f g ⁻¹' {x}) :=
      by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
⊢ ∑ x in SimpleFunc.range (pair f g), (x.1 * ↑↑μ (↑(pair f g) ⁻¹' {x}) + x.2 * ↑↑μ (↑(pair f g) ⁻¹' {x})) =
    ∑ x in SimpleFunc.range (pair f g), x.1 * ↑↑μ (↑(pair f g) ⁻¹' {x}) +
      ∑ x in SimpleFunc.range (pair f g), x.2 * ↑↑μ (↑(pair f g) ⁻¹' {x})

Next tactic:
rw [Finset.sum_add_distrib]
theorem add_lintegral (f g : α →ₛ ℝ≥0∞) : (f + g).lintegral μ = f.lintegral μ + g.lintegral μ :=
  calc
    (f + g).lintegral μ =
        ∑ x in (pair f g).range, (x.1 * μ (pair f g ⁻¹' {x}) + x.2 * μ (pair f g ⁻¹' {x})) :=
      by rw [add_eq_map₂, map_lintegral]; exact Finset.sum_congr rfl fun a _ => add_mul _ _ _
    _ = (∑ x in (pair f g).range, x.1 * μ (pair f g ⁻¹' {x})) +
          ∑ x in (pair f g).range, x.2 * μ (pair f g ⁻¹' {x}) :=
      by rw [Finset.sum_add_distrib]
    _ = ((pair f g).map Prod.fst).lintegral μ + ((pair f g).map Prod.snd).lintegral μ := by
      

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
⊢ ∑ x in SimpleFunc.range (pair f g), x.1 * ↑↑μ (↑(pair f g) ⁻¹' {x}) +
      ∑ x in SimpleFunc.range (pair f g), x.2 * ↑↑μ (↑(pair f g) ⁻¹' {x}) =
    lintegral (map Prod.fst (pair f g)) μ + lintegral (map Prod.snd (pair f g)) μ

Next tactic:
rw [map_lintegral, map_lintegral]
/-- Integral of a simple function `α →ₛ ℝ≥0∞` as a bilinear map. -/
def lintegralₗ {m : MeasurableSpace α} : (α →ₛ ℝ≥0∞) →ₗ[ℝ≥0∞] Measure α →ₗ[ℝ≥0∞] ℝ≥0∞ where
  toFun f :=
    { toFun := lintegral f
      map_add' := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m✝ : MeasurableSpace α
μ ν : Measure α
m : MeasurableSpace α
f : α →ₛ ℝ≥0∞
⊢ ∀ (x y : Measure α), lintegral f (x + y) = lintegral f x + lintegral f y

Next tactic:
simp [lintegral, mul_add, Finset.sum_add_distrib]
/-- Integral of a simple function `α →ₛ ℝ≥0∞` as a bilinear map. -/
def lintegralₗ {m : MeasurableSpace α} : (α →ₛ ℝ≥0∞) →ₗ[ℝ≥0∞] Measure α →ₗ[ℝ≥0∞] ℝ≥0∞ where
  toFun f :=
    { toFun := lintegral f
      map_add' := by simp [lintegral, mul_add, Finset.sum_add_distrib]
      map_smul' := fun c μ => by
        

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m✝ : MeasurableSpace α
μ✝ ν : Measure α
m : MeasurableSpace α
f : α →ₛ ℝ≥0∞
c : ℝ≥0∞
μ : Measure α
⊢ AddHom.toFun
      { toFun := lintegral f,
        map_add' :=
          (_ :
            ∀ (a a_1 : Measure α),
              ∑ x in SimpleFunc.range f, x * ↑↑(a + a_1) (↑f ⁻¹' {x}) =
                ∑ x in SimpleFunc.range f, x * ↑↑a (↑f ⁻¹' {x}) + ∑ x in SimpleFunc.range f, x * ↑↑a_1 (↑f ⁻¹' {x})) }
      (c • μ) =
    (RingHom.id ℝ≥0∞) c •
      AddHom.toFun
        { toFun := lintegral f,
          map_add' :=
            (_ :
              ∀ (a a_1 : Measure α),
                ∑ x in SimpleFunc.range f, x * ↑↑(a + a_1) (↑f ⁻¹' {x}) =
                  ∑ x in SimpleFunc.range f, x * ↑↑a (↑f ⁻¹' {x}) + ∑ x in SimpleFunc.range f, x * ↑↑a_1 (↑f ⁻¹' {x})) }
        μ

Next tactic:
simp [lintegral, mul_left_comm _ c, Finset.mul_sum, Measure.smul_apply c]
theorem lintegral_sum {m : MeasurableSpace α} {ι} (f : α →ₛ ℝ≥0∞) (μ : ι → Measure α) :
    f.lintegral (Measure.sum μ) = ∑' i, f.lintegral (μ i) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m✝ : MeasurableSpace α
μ✝ ν : Measure α
m : MeasurableSpace α
ι : Type u_5
f : α →ₛ ℝ≥0∞
μ : ι → Measure α
⊢ lintegral f (Measure.sum μ) = ∑' (i : ι), lintegral f (μ i)

Next tactic:
simp only [lintegral, Measure.sum_apply, f.measurableSet_preimage, ← Finset.tsum_subtype, ←
    ENNReal.tsum_mul_left]
theorem lintegral_sum {m : MeasurableSpace α} {ι} (f : α →ₛ ℝ≥0∞) (μ : ι → Measure α) :
    f.lintegral (Measure.sum μ) = ∑' i, f.lintegral (μ i) := by
  simp only [lintegral, Measure.sum_apply, f.measurableSet_preimage, ← Finset.tsum_subtype, ←
    ENNReal.tsum_mul_left]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m✝ : MeasurableSpace α
μ✝ ν : Measure α
m : MeasurableSpace α
ι : Type u_5
f : α →ₛ ℝ≥0∞
μ : ι → Measure α
⊢ ∑' (x : { x // x ∈ SimpleFunc.range f }) (i : ι), ↑x * ↑↑(μ i) (↑f ⁻¹' {↑x}) =
    ∑' (i : ι) (x : { x // x ∈ SimpleFunc.range f }), ↑x * ↑↑(μ i) (↑f ⁻¹' {↑x})

Next tactic:
apply ENNReal.tsum_comm
theorem restrict_lintegral (f : α →ₛ ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) :
    (restrict f s).lintegral μ = ∑ r in f.range, r * μ (f ⁻¹' {r} ∩ s) :=
  calc
    (restrict f s).lintegral μ = ∑ r in f.range, r * μ (restrict f s ⁻¹' {r}) :=
      lintegral_eq_of_subset _ fun x hx =>
        if hxs : x ∈ s then fun _ => by
          

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Set α
hs : MeasurableSet s
x : α
hx : ↑(restrict f s) x ≠ 0
hxs : x ∈ s
x✝ : ↑↑μ (↑(restrict f s) ⁻¹' {↑(restrict f s) x}) ≠ 0
⊢ ↑(restrict f s) x ∈ SimpleFunc.range f

Next tactic:
simp only [f.restrict_apply hs, indicator_of_mem hxs, mem_range_self]
theorem restrict_lintegral (f : α →ₛ ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) :
    (restrict f s).lintegral μ = ∑ r in f.range, r * μ (f ⁻¹' {r} ∩ s) :=
  calc
    (restrict f s).lintegral μ = ∑ r in f.range, r * μ (restrict f s ⁻¹' {r}) :=
      lintegral_eq_of_subset _ fun x hx =>
        if hxs : x ∈ s then fun _ => by
          simp only [f.restrict_apply hs, indicator_of_mem hxs, mem_range_self]
        else False.elim <| hx <| by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Set α
hs : MeasurableSet s
x : α
hx : ↑(restrict f s) x ≠ 0
hxs : x ∉ s
⊢ ↑(restrict f s) x = 0

Next tactic:
simp [*]
theorem restrict_lintegral (f : α →ₛ ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) :
    (restrict f s).lintegral μ = ∑ r in f.range, r * μ (f ⁻¹' {r} ∩ s) :=
  calc
    (restrict f s).lintegral μ = ∑ r in f.range, r * μ (restrict f s ⁻¹' {r}) :=
      lintegral_eq_of_subset _ fun x hx =>
        if hxs : x ∈ s then fun _ => by
          simp only [f.restrict_apply hs, indicator_of_mem hxs, mem_range_self]
        else False.elim <| hx <| by simp [*]
    _ = ∑ r in f.range, r * μ (f ⁻¹' {r} ∩ s) :=
      Finset.sum_congr rfl <|
        forall_range_iff.2 fun b =>
          if hb : f b = 0 then by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Set α
hs : MeasurableSet s
b : α
hb : ↑f b = 0
⊢ ↑f b * ↑↑μ (↑(restrict f s) ⁻¹' {↑f b}) = ↑f b * ↑↑μ (↑f ⁻¹' {↑f b} ∩ s)

Next tactic:
simp only [hb, zero_mul]
theorem restrict_lintegral (f : α →ₛ ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) :
    (restrict f s).lintegral μ = ∑ r in f.range, r * μ (f ⁻¹' {r} ∩ s) :=
  calc
    (restrict f s).lintegral μ = ∑ r in f.range, r * μ (restrict f s ⁻¹' {r}) :=
      lintegral_eq_of_subset _ fun x hx =>
        if hxs : x ∈ s then fun _ => by
          simp only [f.restrict_apply hs, indicator_of_mem hxs, mem_range_self]
        else False.elim <| hx <| by simp [*]
    _ = ∑ r in f.range, r * μ (f ⁻¹' {r} ∩ s) :=
      Finset.sum_congr rfl <|
        forall_range_iff.2 fun b =>
          if hb : f b = 0 then by simp only [hb, zero_mul]
          else by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Set α
hs : MeasurableSet s
b : α
hb : ¬↑f b = 0
⊢ ↑f b * ↑↑μ (↑(restrict f s) ⁻¹' {↑f b}) = ↑f b * ↑↑μ (↑f ⁻¹' {↑f b} ∩ s)

Next tactic:
rw [restrict_preimage_singleton _ hs hb, inter_comm]
theorem lintegral_restrict {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (s : Set α) (μ : Measure α) :
    f.lintegral (μ.restrict s) = ∑ y in f.range, y * μ (f ⁻¹' {y} ∩ s) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m✝ : MeasurableSpace α
μ✝ ν : Measure α
m : MeasurableSpace α
f : α →ₛ ℝ≥0∞
s : Set α
μ : Measure α
⊢ lintegral f (Measure.restrict μ s) = ∑ y in SimpleFunc.range f, y * ↑↑μ (↑f ⁻¹' {y} ∩ s)

Next tactic:
simp only [lintegral, Measure.restrict_apply, f.measurableSet_preimage]
theorem restrict_lintegral_eq_lintegral_restrict (f : α →ₛ ℝ≥0∞) {s : Set α}
    (hs : MeasurableSet s) : (restrict f s).lintegral μ = f.lintegral (μ.restrict s) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ lintegral (restrict f s) μ = lintegral f (Measure.restrict μ s)

Next tactic:
rw [f.restrict_lintegral hs, lintegral_restrict]
theorem const_lintegral (c : ℝ≥0∞) : (const α c).lintegral μ = c * μ univ := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
c : ℝ≥0∞
⊢ lintegral (const α c) μ = c * ↑↑μ univ

Next tactic:
rw [lintegral]
theorem const_lintegral (c : ℝ≥0∞) : (const α c).lintegral μ = c * μ univ := by
  rw [lintegral]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
c : ℝ≥0∞
⊢ ∑ x in SimpleFunc.range (const α c), x * ↑↑μ (↑(const α c) ⁻¹' {x}) = c * ↑↑μ univ

Next tactic:
cases isEmpty_or_nonempty α
theorem const_lintegral (c : ℝ≥0∞) : (const α c).lintegral μ = c * μ univ := by
  rw [lintegral]
  cases isEmpty_or_nonempty α
  · 

Proof state:
case inl
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
c : ℝ≥0∞
h✝ : IsEmpty α
⊢ ∑ x in SimpleFunc.range (const α c), x * ↑↑μ (↑(const α c) ⁻¹' {x}) = c * ↑↑μ univ

Next tactic:
simp [μ.eq_zero_of_isEmpty]
theorem const_lintegral (c : ℝ≥0∞) : (const α c).lintegral μ = c * μ univ := by
  rw [lintegral]
  cases isEmpty_or_nonempty α
  · simp [μ.eq_zero_of_isEmpty]
  · 

Proof state:
case inr
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
c : ℝ≥0∞
h✝ : Nonempty α
⊢ ∑ x in SimpleFunc.range (const α c), x * ↑↑μ (↑(const α c) ⁻¹' {x}) = c * ↑↑μ univ

Next tactic:
simp
theorem const_lintegral (c : ℝ≥0∞) : (const α c).lintegral μ = c * μ univ := by
  rw [lintegral]
  cases isEmpty_or_nonempty α
  · simp [μ.eq_zero_of_isEmpty]
  · simp; 

Proof state:
case inr
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
c : ℝ≥0∞
h✝ : Nonempty α
⊢ c * ↑↑μ (Function.const α c ⁻¹' {c}) = c * ↑↑μ univ

Next tactic:
unfold Function.const
theorem const_lintegral (c : ℝ≥0∞) : (const α c).lintegral μ = c * μ univ := by
  rw [lintegral]
  cases isEmpty_or_nonempty α
  · simp [μ.eq_zero_of_isEmpty]
  · simp; unfold Function.const; 

Proof state:
case inr
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
c : ℝ≥0∞
h✝ : Nonempty α
⊢ c * ↑↑μ ((fun x => c) ⁻¹' {c}) = c * ↑↑μ univ

Next tactic:
rw [preimage_const_of_mem (mem_singleton c)]
theorem const_lintegral_restrict (c : ℝ≥0∞) (s : Set α) :
    (const α c).lintegral (μ.restrict s) = c * μ s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
c : ℝ≥0∞
s : Set α
⊢ lintegral (const α c) (Measure.restrict μ s) = c * ↑↑μ s

Next tactic:
rw [const_lintegral, Measure.restrict_apply MeasurableSet.univ, univ_inter]
theorem restrict_const_lintegral (c : ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) :
    ((const α c).restrict s).lintegral μ = c * μ s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
c : ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ lintegral (restrict (const α c) s) μ = c * ↑↑μ s

Next tactic:
rw [restrict_lintegral_eq_lintegral_restrict _ hs, const_lintegral_restrict]
theorem le_sup_lintegral (f g : α →ₛ ℝ≥0∞) : f.lintegral μ ⊔ g.lintegral μ ≤ (f ⊔ g).lintegral μ :=
  calc
    f.lintegral μ ⊔ g.lintegral μ =
        ((pair f g).map Prod.fst).lintegral μ ⊔ ((pair f g).map Prod.snd).lintegral μ :=
      rfl
    _ ≤ ∑ x in (pair f g).range, (x.1 ⊔ x.2) * μ (pair f g ⁻¹' {x}) := by
      

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
⊢ lintegral (map Prod.fst (pair f g)) μ ⊔ lintegral (map Prod.snd (pair f g)) μ ≤
    ∑ x in SimpleFunc.range (pair f g), (x.1 ⊔ x.2) * ↑↑μ (↑(pair f g) ⁻¹' {x})

Next tactic:
rw [map_lintegral, map_lintegral]
theorem le_sup_lintegral (f g : α →ₛ ℝ≥0∞) : f.lintegral μ ⊔ g.lintegral μ ≤ (f ⊔ g).lintegral μ :=
  calc
    f.lintegral μ ⊔ g.lintegral μ =
        ((pair f g).map Prod.fst).lintegral μ ⊔ ((pair f g).map Prod.snd).lintegral μ :=
      rfl
    _ ≤ ∑ x in (pair f g).range, (x.1 ⊔ x.2) * μ (pair f g ⁻¹' {x}) := by
      rw [map_lintegral, map_lintegral]
      

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
⊢ (∑ x in SimpleFunc.range (pair f g), x.1 * ↑↑μ (↑(pair f g) ⁻¹' {x})) ⊔
      ∑ x in SimpleFunc.range (pair f g), x.2 * ↑↑μ (↑(pair f g) ⁻¹' {x}) ≤
    ∑ x in SimpleFunc.range (pair f g), (x.1 ⊔ x.2) * ↑↑μ (↑(pair f g) ⁻¹' {x})

Next tactic:
refine' sup_le _ _
theorem le_sup_lintegral (f g : α →ₛ ℝ≥0∞) : f.lintegral μ ⊔ g.lintegral μ ≤ (f ⊔ g).lintegral μ :=
  calc
    f.lintegral μ ⊔ g.lintegral μ =
        ((pair f g).map Prod.fst).lintegral μ ⊔ ((pair f g).map Prod.snd).lintegral μ :=
      rfl
    _ ≤ ∑ x in (pair f g).range, (x.1 ⊔ x.2) * μ (pair f g ⁻¹' {x}) := by
      rw [map_lintegral, map_lintegral]
      refine' sup_le _ _ <;> 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
⊢ ∑ x in SimpleFunc.range (pair f g), x.1 * ↑↑μ (↑(pair f g) ⁻¹' {x}) ≤
    ∑ x in SimpleFunc.range (pair f g), (x.1 ⊔ x.2) * ↑↑μ (↑(pair f g) ⁻¹' {x})

Next tactic:
refine' Finset.sum_le_sum fun a _ => mul_le_mul_right' _ _
theorem le_sup_lintegral (f g : α →ₛ ℝ≥0∞) : f.lintegral μ ⊔ g.lintegral μ ≤ (f ⊔ g).lintegral μ :=
  calc
    f.lintegral μ ⊔ g.lintegral μ =
        ((pair f g).map Prod.fst).lintegral μ ⊔ ((pair f g).map Prod.snd).lintegral μ :=
      rfl
    _ ≤ ∑ x in (pair f g).range, (x.1 ⊔ x.2) * μ (pair f g ⁻¹' {x}) := by
      rw [map_lintegral, map_lintegral]
      refine' sup_le _ _ <;> 

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
⊢ ∑ x in SimpleFunc.range (pair f g), x.2 * ↑↑μ (↑(pair f g) ⁻¹' {x}) ≤
    ∑ x in SimpleFunc.range (pair f g), (x.1 ⊔ x.2) * ↑↑μ (↑(pair f g) ⁻¹' {x})

Next tactic:
refine' Finset.sum_le_sum fun a _ => mul_le_mul_right' _ _
theorem le_sup_lintegral (f g : α →ₛ ℝ≥0∞) : f.lintegral μ ⊔ g.lintegral μ ≤ (f ⊔ g).lintegral μ :=
  calc
    f.lintegral μ ⊔ g.lintegral μ =
        ((pair f g).map Prod.fst).lintegral μ ⊔ ((pair f g).map Prod.snd).lintegral μ :=
      rfl
    _ ≤ ∑ x in (pair f g).range, (x.1 ⊔ x.2) * μ (pair f g ⁻¹' {x}) := by
      rw [map_lintegral, map_lintegral]
      refine' sup_le _ _ <;> refine' Finset.sum_le_sum fun a _ => mul_le_mul_right' _ _
      · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
a : ℝ≥0∞ × ℝ≥0∞
x✝ : a ∈ SimpleFunc.range (pair f g)
⊢ a.1 ≤ a.1 ⊔ a.2

Next tactic:
exact le_sup_left
theorem le_sup_lintegral (f g : α →ₛ ℝ≥0∞) : f.lintegral μ ⊔ g.lintegral μ ≤ (f ⊔ g).lintegral μ :=
  calc
    f.lintegral μ ⊔ g.lintegral μ =
        ((pair f g).map Prod.fst).lintegral μ ⊔ ((pair f g).map Prod.snd).lintegral μ :=
      rfl
    _ ≤ ∑ x in (pair f g).range, (x.1 ⊔ x.2) * μ (pair f g ⁻¹' {x}) := by
      rw [map_lintegral, map_lintegral]
      refine' sup_le _ _ <;> refine' Finset.sum_le_sum fun a _ => mul_le_mul_right' _ _
      · exact le_sup_left
      · 

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
a : ℝ≥0∞ × ℝ≥0∞
x✝ : a ∈ SimpleFunc.range (pair f g)
⊢ a.2 ≤ a.1 ⊔ a.2

Next tactic:
exact le_sup_right
theorem le_sup_lintegral (f g : α →ₛ ℝ≥0∞) : f.lintegral μ ⊔ g.lintegral μ ≤ (f ⊔ g).lintegral μ :=
  calc
    f.lintegral μ ⊔ g.lintegral μ =
        ((pair f g).map Prod.fst).lintegral μ ⊔ ((pair f g).map Prod.snd).lintegral μ :=
      rfl
    _ ≤ ∑ x in (pair f g).range, (x.1 ⊔ x.2) * μ (pair f g ⁻¹' {x}) := by
      rw [map_lintegral, map_lintegral]
      refine' sup_le _ _ <;> refine' Finset.sum_le_sum fun a _ => mul_le_mul_right' _ _
      · exact le_sup_left
      · exact le_sup_right
    _ = (f ⊔ g).lintegral μ := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
⊢ ∑ x in SimpleFunc.range (pair f g), (x.1 ⊔ x.2) * ↑↑μ (↑(pair f g) ⁻¹' {x}) = lintegral (f ⊔ g) μ

Next tactic:
rw [sup_eq_map₂, map_lintegral]
/-- `SimpleFunc.lintegral` is monotone both in function and in measure. -/
@[mono]
theorem lintegral_mono {f g : α →ₛ ℝ≥0∞} (hfg : f ≤ g) (hμν : μ ≤ ν) :
    f.lintegral μ ≤ g.lintegral ν :=
  calc
    f.lintegral μ ≤ f.lintegral μ ⊔ g.lintegral μ := le_sup_left
    _ ≤ (f ⊔ g).lintegral μ := (le_sup_lintegral _ _)
    _ = g.lintegral μ := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f g : α →ₛ ℝ≥0∞
hfg : f ≤ g
hμν : μ ≤ ν
⊢ lintegral (f ⊔ g) μ = lintegral g μ

Next tactic:
rw [sup_of_le_right hfg]