l3lab/ntp-mathlib huggingface dataset:
theorem set_integral_nonpos_le {s : Set α} (hs : MeasurableSet s) (hf : StronglyMeasurable f)
    (hfi : Integrable f μ) : (∫ x in {y | f y ≤ 0}, f x ∂μ) ≤ ∫ x in s, f x ∂μ := by
  rw [← integral_indicator hs, ←
    integral_indicator (hf.measurableSet_le stronglyMeasurable_const)]
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
s✝ s : Set α
hs : MeasurableSet s
hf : StronglyMeasurable f
hfi : Integrable f
⊢ ∫ (x : α), indicator {a | f a ≤ 0} (fun x => f x) x ∂μ ≤ ∫ (x : α), indicator s (fun x => f x) x ∂μ

Next tactic:
exact
    integral_mono (hfi.indicator (hf.measurableSet_le stronglyMeasurable_const))
      (hfi.indicator hs) (indicator_nonpos_le_indicator s f)
lemma Integrable.measure_le_integral {f : α → ℝ} (f_int : Integrable f μ) (f_nonneg : 0 ≤ᵐ[μ] f)
    {s : Set α} (hs : ∀ x ∈ s, 1 ≤ f x) :
    μ s ≤ ENNReal.ofReal (∫ x, f x ∂μ) := by
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
f_int : Integrable f
f_nonneg : 0 ≤ᵐ[μ] f
s : Set α
hs : ∀ x ∈ s, 1 ≤ f x
⊢ ↑↑μ s ≤ ENNReal.ofReal (∫ (x : α), f x ∂μ)

Next tactic:
rw [ofReal_integral_eq_lintegral_ofReal f_int f_nonneg]
lemma Integrable.measure_le_integral {f : α → ℝ} (f_int : Integrable f μ) (f_nonneg : 0 ≤ᵐ[μ] f)
    {s : Set α} (hs : ∀ x ∈ s, 1 ≤ f x) :
    μ s ≤ ENNReal.ofReal (∫ x, f x ∂μ) := by
  rw [ofReal_integral_eq_lintegral_ofReal f_int f_nonneg]
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
f_int : Integrable f
f_nonneg : 0 ≤ᵐ[μ] f
s : Set α
hs : ∀ x ∈ s, 1 ≤ f x
⊢ ↑↑μ s ≤ ∫⁻ (x : α), ENNReal.ofReal (f x) ∂μ

Next tactic:
apply meas_le_lintegral₀
lemma Integrable.measure_le_integral {f : α → ℝ} (f_int : Integrable f μ) (f_nonneg : 0 ≤ᵐ[μ] f)
    {s : Set α} (hs : ∀ x ∈ s, 1 ≤ f x) :
    μ s ≤ ENNReal.ofReal (∫ x, f x ∂μ) := by
  rw [ofReal_integral_eq_lintegral_ofReal f_int f_nonneg]
  apply meas_le_lintegral₀
  · 

Proof state:
case hf
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
f_int : Integrable f
f_nonneg : 0 ≤ᵐ[μ] f
s : Set α
hs : ∀ x ∈ s, 1 ≤ f x
⊢ AEMeasurable fun a => ENNReal.ofReal (f a)

Next tactic:
exact ENNReal.continuous_ofReal.measurable.comp_aemeasurable f_int.1.aemeasurable
lemma Integrable.measure_le_integral {f : α → ℝ} (f_int : Integrable f μ) (f_nonneg : 0 ≤ᵐ[μ] f)
    {s : Set α} (hs : ∀ x ∈ s, 1 ≤ f x) :
    μ s ≤ ENNReal.ofReal (∫ x, f x ∂μ) := by
  rw [ofReal_integral_eq_lintegral_ofReal f_int f_nonneg]
  apply meas_le_lintegral₀
  · exact ENNReal.continuous_ofReal.measurable.comp_aemeasurable f_int.1.aemeasurable
  · 

Proof state:
case hs
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
f_int : Integrable f
f_nonneg : 0 ≤ᵐ[μ] f
s : Set α
hs : ∀ x ∈ s, 1 ≤ f x
⊢ ∀ x ∈ s, 1 ≤ ENNReal.ofReal (f x)

Next tactic:
intro x hx
lemma Integrable.measure_le_integral {f : α → ℝ} (f_int : Integrable f μ) (f_nonneg : 0 ≤ᵐ[μ] f)
    {s : Set α} (hs : ∀ x ∈ s, 1 ≤ f x) :
    μ s ≤ ENNReal.ofReal (∫ x, f x ∂μ) := by
  rw [ofReal_integral_eq_lintegral_ofReal f_int f_nonneg]
  apply meas_le_lintegral₀
  · exact ENNReal.continuous_ofReal.measurable.comp_aemeasurable f_int.1.aemeasurable
  · intro x hx
    

Proof state:
case hs
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
f_int : Integrable f
f_nonneg : 0 ≤ᵐ[μ] f
s : Set α
hs : ∀ x ∈ s, 1 ≤ f x
x : α
hx : x ∈ s
⊢ 1 ≤ ENNReal.ofReal (f x)

Next tactic:
simpa using ENNReal.ofReal_le_ofReal (hs x hx)
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
⊢ ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ↑↑μ s

Next tactic:
by_cases H : Integrable f μ
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; 

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
⊢ ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ↑↑μ s
case neg
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : ¬Integrable f
⊢ ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ↑↑μ s

Next tactic:
swap
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : ¬Integrable f
⊢ ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ↑↑μ s

Next tactic:
simp [integral_undef H]
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
⊢ ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ↑↑μ s

Next tactic:
let g x := max (f x) 0
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
⊢ ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ↑↑μ s

Next tactic:
have g_int : Integrable g μ := H.pos_part
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
⊢ ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ↑↑μ s

Next tactic:
have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
⊢ ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)

Next tactic:
apply ENNReal.ofReal_le_ofReal
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    

Proof state:
case h
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
⊢ ∫ (x : α), f x ∂μ ≤ ∫ (x : α), g x ∂μ

Next tactic:
exact integral_mono H g_int (fun x ↦ le_max_left _ _)
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
⊢ ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ↑↑μ s

Next tactic:
apply this.trans
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  apply this.trans
  

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
⊢ ENNReal.ofReal (∫ (x : α), g x ∂μ) ≤ ↑↑μ s

Next tactic:
rw [ofReal_integral_eq_lintegral_ofReal g_int (eventually_of_forall (fun x ↦ le_max_right _ _))]
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  apply this.trans
  rw [ofReal_integral_eq_lintegral_ofReal g_int (eventually_of_forall (fun x ↦ le_max_right _ _))]
  

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
⊢ ∫⁻ (x : α), ENNReal.ofReal (g x) ∂μ ≤ ↑↑μ s

Next tactic:
apply lintegral_le_meas
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  apply this.trans
  rw [ofReal_integral_eq_lintegral_ofReal g_int (eventually_of_forall (fun x ↦ le_max_right _ _))]
  apply lintegral_le_meas
  · 

Proof state:
case pos.hf
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
⊢ ∀ (a : α), ENNReal.ofReal (g a) ≤ 1

Next tactic:
intro x
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  apply this.trans
  rw [ofReal_integral_eq_lintegral_ofReal g_int (eventually_of_forall (fun x ↦ le_max_right _ _))]
  apply lintegral_le_meas
  · intro x
    

Proof state:
case pos.hf
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
x : α
⊢ ENNReal.ofReal (g x) ≤ 1

Next tactic:
apply ENNReal.ofReal_le_of_le_toReal
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  apply this.trans
  rw [ofReal_integral_eq_lintegral_ofReal g_int (eventually_of_forall (fun x ↦ le_max_right _ _))]
  apply lintegral_le_meas
  · intro x
    apply ENNReal.ofReal_le_of_le_toReal
    

Proof state:
case pos.hf.h
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
x : α
⊢ g x ≤ ENNReal.toReal 1

Next tactic:
by_cases H : x ∈ s
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  apply this.trans
  rw [ofReal_integral_eq_lintegral_ofReal g_int (eventually_of_forall (fun x ↦ le_max_right _ _))]
  apply lintegral_le_meas
  · intro x
    apply ENNReal.ofReal_le_of_le_toReal
    by_cases H : x ∈ s
    · 

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H✝ : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
x : α
H : x ∈ s
⊢ g x ≤ ENNReal.toReal 1

Next tactic:
simpa using hs x H
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  apply this.trans
  rw [ofReal_integral_eq_lintegral_ofReal g_int (eventually_of_forall (fun x ↦ le_max_right _ _))]
  apply lintegral_le_meas
  · intro x
    apply ENNReal.ofReal_le_of_le_toReal
    by_cases H : x ∈ s
    · simpa using hs x H
    · 

Proof state:
case neg
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H✝ : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
x : α
H : x ∉ s
⊢ g x ≤ ENNReal.toReal 1

Next tactic:
apply le_trans _ zero_le_one
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  apply this.trans
  rw [ofReal_integral_eq_lintegral_ofReal g_int (eventually_of_forall (fun x ↦ le_max_right _ _))]
  apply lintegral_le_meas
  · intro x
    apply ENNReal.ofReal_le_of_le_toReal
    by_cases H : x ∈ s
    · simpa using hs x H
    · apply le_trans _ zero_le_one
      

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H✝ : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
x : α
H : x ∉ s
⊢ g x ≤ 0

Next tactic:
simpa using h's x H
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  apply this.trans
  rw [ofReal_integral_eq_lintegral_ofReal g_int (eventually_of_forall (fun x ↦ le_max_right _ _))]
  apply lintegral_le_meas
  · intro x
    apply ENNReal.ofReal_le_of_le_toReal
    by_cases H : x ∈ s
    · simpa using hs x H
    · apply le_trans _ zero_le_one
      simpa using h's x H
  · 

Proof state:
case pos.h'f
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
⊢ ∀ a ∈ sᶜ, ENNReal.ofReal (g a) = 0

Next tactic:
intro x hx
lemma integral_le_measure {f : α → ℝ} {s : Set α}
    (hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
    ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
  by_cases H : Integrable f μ; swap
  · simp [integral_undef H]
  let g x := max (f x) 0
  have g_int : Integrable g μ := H.pos_part
  have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
    apply ENNReal.ofReal_le_ofReal
    exact integral_mono H g_int (fun x ↦ le_max_left _ _)
  apply this.trans
  rw [ofReal_integral_eq_lintegral_ofReal g_int (eventually_of_forall (fun x ↦ le_max_right _ _))]
  apply lintegral_le_meas
  · intro x
    apply ENNReal.ofReal_le_of_le_toReal
    by_cases H : x ∈ s
    · simpa using hs x H
    · apply le_trans _ zero_le_one
      simpa using h's x H
  · intro x hx
    

Proof state:
case pos.h'f
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝ : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s✝ : Set α
f : α → ℝ
s : Set α
hs : ∀ x ∈ s, f x ≤ 1
h's : ∀ x ∈ sᶜ, f x ≤ 0
H : Integrable f
g : α → ℝ := fun x => max (f x) 0
g_int : Integrable g
this : ENNReal.ofReal (∫ (x : α), f x ∂μ) ≤ ENNReal.ofReal (∫ (x : α), g x ∂μ)
x : α
hx : x ∈ sᶜ
⊢ ENNReal.ofReal (g x) = 0

Next tactic:
simpa using h's x hx
theorem integrableOn_iUnion_of_summable_integral_norm {f : α → E} {s : β → Set α}
    (hs : ∀ b : β, MeasurableSet (s b)) (hi : ∀ b : β, IntegrableOn f (s b) μ)
    (h : Summable fun b : β => ∫ a : α in s b, ‖f a‖ ∂μ) : IntegrableOn f (iUnion s) μ := by
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup E
inst✝ : Countable β
f : α → E
s : β → Set α
hs : ∀ (b : β), MeasurableSet (s b)
hi : ∀ (b : β), IntegrableOn f (s b)
h : Summable fun b => ∫ (a : α) in s b, ‖f a‖ ∂μ
⊢ IntegrableOn f (iUnion s)

Next tactic:
refine' ⟨AEStronglyMeasurable.iUnion fun i => (hi i).1, (lintegral_iUnion_le _ _).trans_lt _⟩
theorem integrableOn_iUnion_of_summable_integral_norm {f : α → E} {s : β → Set α}
    (hs : ∀ b : β, MeasurableSet (s b)) (hi : ∀ b : β, IntegrableOn f (s b) μ)
    (h : Summable fun b : β => ∫ a : α in s b, ‖f a‖ ∂μ) : IntegrableOn f (iUnion s) μ := by
  refine' ⟨AEStronglyMeasurable.iUnion fun i => (hi i).1, (lintegral_iUnion_le _ _).trans_lt _⟩
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup E
inst✝ : Countable β
f : α → E
s : β → Set α
hs : ∀ (b : β), MeasurableSet (s b)
hi : ∀ (b : β), IntegrableOn f (s b)
h : Summable fun b => ∫ (a : α) in s b, ‖f a‖ ∂μ
⊢ ∑' (i : β), ∫⁻ (a : α) in s i, ↑‖f a‖₊ ∂μ < ⊤

Next tactic:
have B := fun b : β => lintegral_coe_eq_integral (fun a : α => ‖f a‖₊) (hi b).norm
theorem integrableOn_iUnion_of_summable_integral_norm {f : α → E} {s : β → Set α}
    (hs : ∀ b : β, MeasurableSet (s b)) (hi : ∀ b : β, IntegrableOn f (s b) μ)
    (h : Summable fun b : β => ∫ a : α in s b, ‖f a‖ ∂μ) : IntegrableOn f (iUnion s) μ := by
  refine' ⟨AEStronglyMeasurable.iUnion fun i => (hi i).1, (lintegral_iUnion_le _ _).trans_lt _⟩
  have B := fun b : β => lintegral_coe_eq_integral (fun a : α => ‖f a‖₊) (hi b).norm
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup E
inst✝ : Countable β
f : α → E
s : β → Set α
hs : ∀ (b : β), MeasurableSet (s b)
hi : ∀ (b : β), IntegrableOn f (s b)
h : Summable fun b => ∫ (a : α) in s b, ‖f a‖ ∂μ
B : ∀ (b : β), ∫⁻ (a : α) in s b, ↑‖f a‖₊ ∂μ = ENNReal.ofReal (∫ (a : α) in s b, ↑‖f a‖₊ ∂μ)
⊢ ∑' (i : β), ∫⁻ (a : α) in s i, ↑‖f a‖₊ ∂μ < ⊤

Next tactic:
rw [tsum_congr B]
theorem integrableOn_iUnion_of_summable_integral_norm {f : α → E} {s : β → Set α}
    (hs : ∀ b : β, MeasurableSet (s b)) (hi : ∀ b : β, IntegrableOn f (s b) μ)
    (h : Summable fun b : β => ∫ a : α in s b, ‖f a‖ ∂μ) : IntegrableOn f (iUnion s) μ := by
  refine' ⟨AEStronglyMeasurable.iUnion fun i => (hi i).1, (lintegral_iUnion_le _ _).trans_lt _⟩
  have B := fun b : β => lintegral_coe_eq_integral (fun a : α => ‖f a‖₊) (hi b).norm
  rw [tsum_congr B]
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup E
inst✝ : Countable β
f : α → E
s : β → Set α
hs : ∀ (b : β), MeasurableSet (s b)
hi : ∀ (b : β), IntegrableOn f (s b)
h : Summable fun b => ∫ (a : α) in s b, ‖f a‖ ∂μ
B : ∀ (b : β), ∫⁻ (a : α) in s b, ↑‖f a‖₊ ∂μ = ENNReal.ofReal (∫ (a : α) in s b, ↑‖f a‖₊ ∂μ)
⊢ ∑' (b : β), ENNReal.ofReal (∫ (a : α) in s b, ↑‖f a‖₊ ∂μ) < ⊤

Next tactic:
have S' :
    Summable fun b : β =>
      (⟨∫ a : α in s b, ‖f a‖₊ ∂μ, set_integral_nonneg (hs b) fun a _ => NNReal.coe_nonneg _⟩ :
        NNReal) :=
    by rw [← NNReal.summable_coe]; exact h