l3lab/ntp-mathlib huggingface dataset:
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero_aux (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) (haux : StronglyMeasurable f)
    (h'aux : IntegrableOn f t μ) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  let k := f ⁻¹' {0}
  have hk : MeasurableSet k := by borelize E; exact haux.measurable (measurableSet_singleton _)
  calc
    ∫ x in t, f x ∂μ = (∫ x in t ∩ k, f x ∂μ) + ∫ x in t \ k, f x ∂μ := by
      rw [integral_inter_add_diff hk h'aux]
    _ = ∫ x in t \ k, f x ∂μ := by
      rw [set_integral_eq_zero_of_forall_eq_zero fun x hx => ?_, zero_add]; exact hx.2
    _ = ∫ x in s \ k, f x ∂μ := by
      apply set_integral_congr_set_ae
      filter_upwards [h't] with x hx
      change (x ∈ t \ k) = (x ∈ s \ k)
      simp only [mem_preimage, mem_singleton_iff, eq_iff_iff, and_congr_left_iff, mem_diff]
      intro h'x
      by_cases xs : x ∈ s
      · simp only [xs, hts xs]
      · simp only [xs, iff_false_iff]
        intro xt
        exact h'x (hx ⟨xt, xs⟩)
    _ = (∫ x in s ∩ k, f x ∂μ) + ∫ x in s \ k, f x ∂μ := by
      

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
haux : StronglyMeasurable f
h'aux : IntegrableOn f t
k : Set α := f ⁻¹' {0}
hk : MeasurableSet k
⊢ ∫ (x : α) in s \ k, f x ∂μ = ∫ (x : α) in s ∩ k, f x ∂μ + ∫ (x : α) in s \ k, f x ∂μ

Next tactic:
have : ∀ x ∈ s ∩ k, f x = 0 := fun x hx => hx.2
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero_aux (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) (haux : StronglyMeasurable f)
    (h'aux : IntegrableOn f t μ) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  let k := f ⁻¹' {0}
  have hk : MeasurableSet k := by borelize E; exact haux.measurable (measurableSet_singleton _)
  calc
    ∫ x in t, f x ∂μ = (∫ x in t ∩ k, f x ∂μ) + ∫ x in t \ k, f x ∂μ := by
      rw [integral_inter_add_diff hk h'aux]
    _ = ∫ x in t \ k, f x ∂μ := by
      rw [set_integral_eq_zero_of_forall_eq_zero fun x hx => ?_, zero_add]; exact hx.2
    _ = ∫ x in s \ k, f x ∂μ := by
      apply set_integral_congr_set_ae
      filter_upwards [h't] with x hx
      change (x ∈ t \ k) = (x ∈ s \ k)
      simp only [mem_preimage, mem_singleton_iff, eq_iff_iff, and_congr_left_iff, mem_diff]
      intro h'x
      by_cases xs : x ∈ s
      · simp only [xs, hts xs]
      · simp only [xs, iff_false_iff]
        intro xt
        exact h'x (hx ⟨xt, xs⟩)
    _ = (∫ x in s ∩ k, f x ∂μ) + ∫ x in s \ k, f x ∂μ := by
      have : ∀ x ∈ s ∩ k, f x = 0 := fun x hx => hx.2
      

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
haux : StronglyMeasurable f
h'aux : IntegrableOn f t
k : Set α := f ⁻¹' {0}
hk : MeasurableSet k
this : ∀ x ∈ s ∩ k, f x = 0
⊢ ∫ (x : α) in s \ k, f x ∂μ = ∫ (x : α) in s ∩ k, f x ∂μ + ∫ (x : α) in s \ k, f x ∂μ

Next tactic:
rw [set_integral_eq_zero_of_forall_eq_zero this, zero_add]
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero_aux (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) (haux : StronglyMeasurable f)
    (h'aux : IntegrableOn f t μ) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  let k := f ⁻¹' {0}
  have hk : MeasurableSet k := by borelize E; exact haux.measurable (measurableSet_singleton _)
  calc
    ∫ x in t, f x ∂μ = (∫ x in t ∩ k, f x ∂μ) + ∫ x in t \ k, f x ∂μ := by
      rw [integral_inter_add_diff hk h'aux]
    _ = ∫ x in t \ k, f x ∂μ := by
      rw [set_integral_eq_zero_of_forall_eq_zero fun x hx => ?_, zero_add]; exact hx.2
    _ = ∫ x in s \ k, f x ∂μ := by
      apply set_integral_congr_set_ae
      filter_upwards [h't] with x hx
      change (x ∈ t \ k) = (x ∈ s \ k)
      simp only [mem_preimage, mem_singleton_iff, eq_iff_iff, and_congr_left_iff, mem_diff]
      intro h'x
      by_cases xs : x ∈ s
      · simp only [xs, hts xs]
      · simp only [xs, iff_false_iff]
        intro xt
        exact h'x (hx ⟨xt, xs⟩)
    _ = (∫ x in s ∩ k, f x ∂μ) + ∫ x in s \ k, f x ∂μ := by
      have : ∀ x ∈ s ∩ k, f x = 0 := fun x hx => hx.2
      rw [set_integral_eq_zero_of_forall_eq_zero this, zero_add]
    _ = ∫ x in s, f x ∂μ := by 

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
haux : StronglyMeasurable f
h'aux : IntegrableOn f t
k : Set α := f ⁻¹' {0}
hk : MeasurableSet k
⊢ ∫ (x : α) in s ∩ k, f x ∂μ + ∫ (x : α) in s \ k, f x ∂μ = ∫ (x : α) in s, f x ∂μ

Next tactic:
rw [integral_inter_add_diff hk (h'aux.mono hts le_rfl)]
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
⊢ ∫ (x : α) in t, f x ∂μ = ∫ (x : α) in s, f x ∂μ

Next tactic:
by_cases h : IntegrableOn f t μ
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; 

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : IntegrableOn f t
⊢ ∫ (x : α) in t, f x ∂μ = ∫ (x : α) in s, f x ∂μ
case neg
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : ¬IntegrableOn f t
⊢ ∫ (x : α) in t, f x ∂μ = ∫ (x : α) in s, f x ∂μ

Next tactic:
swap
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; swap
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : ¬IntegrableOn f t
⊢ ∫ (x : α) in t, f x ∂μ = ∫ (x : α) in s, f x ∂μ

Next tactic:
have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; swap
  · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
    

Proof state:
case neg
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : ¬IntegrableOn f t
this : ¬IntegrableOn f s
⊢ ∫ (x : α) in t, f x ∂μ = ∫ (x : α) in s, f x ∂μ

Next tactic:
rw [integral_undef h, integral_undef this]
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; swap
  · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
    rw [integral_undef h, integral_undef this]
  

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : IntegrableOn f t
⊢ ∫ (x : α) in t, f x ∂μ = ∫ (x : α) in s, f x ∂μ

Next tactic:
let f' := h.1.mk f
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; swap
  · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
    rw [integral_undef h, integral_undef this]
  let f' := h.1.mk f
  

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : IntegrableOn f t
f' : α → E := AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f (Measure.restrict μ t))
⊢ ∫ (x : α) in t, f x ∂μ = ∫ (x : α) in s, f x ∂μ

Next tactic:
calc
    ∫ x in t, f x ∂μ = ∫ x in t, f' x ∂μ := integral_congr_ae h.1.ae_eq_mk
    _ = ∫ x in s, f' x ∂μ := by
      apply
        set_integral_eq_of_subset_of_ae_diff_eq_zero_aux hts _ h.1.stronglyMeasurable_mk
          (h.congr h.1.ae_eq_mk)
      filter_upwards [h't, ae_imp_of_ae_restrict h.1.ae_eq_mk] with x hx h'x h''x
      rw [← h'x h''x.1, hx h''x]
    _ = ∫ x in s, f x ∂μ := by
      apply integral_congr_ae
      apply ae_restrict_of_ae_restrict_of_subset hts
      exact h.1.ae_eq_mk.symm
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; swap
  · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
    rw [integral_undef h, integral_undef this]
  let f' := h.1.mk f
  calc
    ∫ x in t, f x ∂μ = ∫ x in t, f' x ∂μ := integral_congr_ae h.1.ae_eq_mk
    _ = ∫ x in s, f' x ∂μ := by
      

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : IntegrableOn f t
f' : α → E := AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f (Measure.restrict μ t))
⊢ ∫ (x : α) in t, f' x ∂μ = ∫ (x : α) in s, f' x ∂μ

Next tactic:
apply
        set_integral_eq_of_subset_of_ae_diff_eq_zero_aux hts _ h.1.stronglyMeasurable_mk
          (h.congr h.1.ae_eq_mk)
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; swap
  · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
    rw [integral_undef h, integral_undef this]
  let f' := h.1.mk f
  calc
    ∫ x in t, f x ∂μ = ∫ x in t, f' x ∂μ := integral_congr_ae h.1.ae_eq_mk
    _ = ∫ x in s, f' x ∂μ := by
      apply
        set_integral_eq_of_subset_of_ae_diff_eq_zero_aux hts _ h.1.stronglyMeasurable_mk
          (h.congr h.1.ae_eq_mk)
      

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : IntegrableOn f t
f' : α → E := AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f (Measure.restrict μ t))
⊢ ∀ᵐ (x : α) ∂μ, x ∈ t \ s → AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f (Measure.restrict μ t)) x = 0

Next tactic:
filter_upwards [h't, ae_imp_of_ae_restrict h.1.ae_eq_mk] with x hx h'x h''x
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; swap
  · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
    rw [integral_undef h, integral_undef this]
  let f' := h.1.mk f
  calc
    ∫ x in t, f x ∂μ = ∫ x in t, f' x ∂μ := integral_congr_ae h.1.ae_eq_mk
    _ = ∫ x in s, f' x ∂μ := by
      apply
        set_integral_eq_of_subset_of_ae_diff_eq_zero_aux hts _ h.1.stronglyMeasurable_mk
          (h.congr h.1.ae_eq_mk)
      filter_upwards [h't, ae_imp_of_ae_restrict h.1.ae_eq_mk] with x hx h'x h''x
      

Proof state:
case h
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : IntegrableOn f t
f' : α → E := AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f (Measure.restrict μ t))
x : α
hx : x ∈ t \ s → f x = 0
h'x : x ∈ t → f x = AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f (Measure.restrict μ t)) x
h''x : x ∈ t \ s
⊢ AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f (Measure.restrict μ t)) x = 0

Next tactic:
rw [← h'x h''x.1, hx h''x]
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; swap
  · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
    rw [integral_undef h, integral_undef this]
  let f' := h.1.mk f
  calc
    ∫ x in t, f x ∂μ = ∫ x in t, f' x ∂μ := integral_congr_ae h.1.ae_eq_mk
    _ = ∫ x in s, f' x ∂μ := by
      apply
        set_integral_eq_of_subset_of_ae_diff_eq_zero_aux hts _ h.1.stronglyMeasurable_mk
          (h.congr h.1.ae_eq_mk)
      filter_upwards [h't, ae_imp_of_ae_restrict h.1.ae_eq_mk] with x hx h'x h''x
      rw [← h'x h''x.1, hx h''x]
    _ = ∫ x in s, f x ∂μ := by
      

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : IntegrableOn f t
f' : α → E := AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f (Measure.restrict μ t))
⊢ ∫ (x : α) in s, f' x ∂μ = ∫ (x : α) in s, f x ∂μ

Next tactic:
apply integral_congr_ae
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; swap
  · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
    rw [integral_undef h, integral_undef this]
  let f' := h.1.mk f
  calc
    ∫ x in t, f x ∂μ = ∫ x in t, f' x ∂μ := integral_congr_ae h.1.ae_eq_mk
    _ = ∫ x in s, f' x ∂μ := by
      apply
        set_integral_eq_of_subset_of_ae_diff_eq_zero_aux hts _ h.1.stronglyMeasurable_mk
          (h.congr h.1.ae_eq_mk)
      filter_upwards [h't, ae_imp_of_ae_restrict h.1.ae_eq_mk] with x hx h'x h''x
      rw [← h'x h''x.1, hx h''x]
    _ = ∫ x in s, f x ∂μ := by
      apply integral_congr_ae
      

Proof state:
case h
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : IntegrableOn f t
f' : α → E := AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f (Measure.restrict μ t))
⊢ (fun a => f' a) =ᵐ[Measure.restrict μ s] fun a => f a

Next tactic:
apply ae_restrict_of_ae_restrict_of_subset hts
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem set_integral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
    (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
  by_cases h : IntegrableOn f t μ; swap
  · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
    rw [integral_undef h, integral_undef this]
  let f' := h.1.mk f
  calc
    ∫ x in t, f x ∂μ = ∫ x in t, f' x ∂μ := integral_congr_ae h.1.ae_eq_mk
    _ = ∫ x in s, f' x ∂μ := by
      apply
        set_integral_eq_of_subset_of_ae_diff_eq_zero_aux hts _ h.1.stronglyMeasurable_mk
          (h.congr h.1.ae_eq_mk)
      filter_upwards [h't, ae_imp_of_ae_restrict h.1.ae_eq_mk] with x hx h'x h''x
      rw [← h'x h''x.1, hx h''x]
    _ = ∫ x in s, f x ∂μ := by
      apply integral_congr_ae
      apply ae_restrict_of_ae_restrict_of_subset hts
      

Proof state:
case h
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht : NullMeasurableSet t
hts : s ⊆ t
h't : ∀ᵐ (x : α) ∂μ, x ∈ t \ s → f x = 0
h : IntegrableOn f t
f' : α → E := AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f (Measure.restrict μ t))
⊢ ∀ᵐ (x : α) ∂Measure.restrict μ t, (fun a => f' a) x = (fun a => f a) x

Next tactic:
exact h.1.ae_eq_mk.symm
/-- If a function vanishes almost everywhere on `sᶜ`, then its integral on `s`
coincides with its integral on the whole space. -/
theorem set_integral_eq_integral_of_ae_compl_eq_zero (h : ∀ᵐ x ∂μ, x ∉ s → f x = 0) :
    ∫ x in s, f x ∂μ = ∫ x, f x ∂μ := by
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
h : ∀ᵐ (x : α) ∂μ, x ∉ s → f x = 0
⊢ ∫ (x : α) in s, f x ∂μ = ∫ (x : α), f x ∂μ

Next tactic:
symm
/-- If a function vanishes almost everywhere on `sᶜ`, then its integral on `s`
coincides with its integral on the whole space. -/
theorem set_integral_eq_integral_of_ae_compl_eq_zero (h : ∀ᵐ x ∂μ, x ∉ s → f x = 0) :
    ∫ x in s, f x ∂μ = ∫ x, f x ∂μ := by
  symm
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
h : ∀ᵐ (x : α) ∂μ, x ∉ s → f x = 0
⊢ ∫ (x : α), f x ∂μ = ∫ (x : α) in s, f x ∂μ

Next tactic:
nth_rw 1 [← integral_univ]
/-- If a function vanishes almost everywhere on `sᶜ`, then its integral on `s`
coincides with its integral on the whole space. -/
theorem set_integral_eq_integral_of_ae_compl_eq_zero (h : ∀ᵐ x ∂μ, x ∉ s → f x = 0) :
    ∫ x in s, f x ∂μ = ∫ x, f x ∂μ := by
  symm
  nth_rw 1 [← integral_univ]
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
h : ∀ᵐ (x : α) ∂μ, x ∉ s → f x = 0
⊢ ∫ (x : α) in univ, f x ∂μ = ∫ (x : α) in s, f x ∂μ

Next tactic:
apply set_integral_eq_of_subset_of_ae_diff_eq_zero nullMeasurableSet_univ (subset_univ _)
/-- If a function vanishes almost everywhere on `sᶜ`, then its integral on `s`
coincides with its integral on the whole space. -/
theorem set_integral_eq_integral_of_ae_compl_eq_zero (h : ∀ᵐ x ∂μ, x ∉ s → f x = 0) :
    ∫ x in s, f x ∂μ = ∫ x, f x ∂μ := by
  symm
  nth_rw 1 [← integral_univ]
  apply set_integral_eq_of_subset_of_ae_diff_eq_zero nullMeasurableSet_univ (subset_univ _)
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
h : ∀ᵐ (x : α) ∂μ, x ∉ s → f x = 0
⊢ ∀ᵐ (x : α) ∂μ, x ∈ univ \ s → f x = 0

Next tactic:
filter_upwards [h] with x hx h'x using hx h'x.2
lemma ae_restrict_eq_const_iff_ae_eq_const_of_mem {E : Type*} [MeasurableSpace E]
    [MeasurableSingletonClass E] {f : α → E} (c : E) {s : Set α}
    (f_mble : NullMeasurable f (μ.restrict s)) :
    f =ᵐ[Measure.restrict μ s] (fun _ ↦ c) ↔ ∀ᵐ x ∂μ, x ∈ s → f x = c := by
  

Proof state:
α : Type u_1
β : Type u_2
E✝ : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E✝
f✝ g : α → E✝
s✝ t : Set α
μ ν : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E✝
E : Type u_5
inst✝¹ : MeasurableSpace E
inst✝ : MeasurableSingletonClass E
f : α → E
c : E
s : Set α
f_mble : NullMeasurable f
⊢ (f =ᵐ[Measure.restrict μ s] fun x => c) ↔ ∀ᵐ (x : α) ∂μ, x ∈ s → f x = c

Next tactic:
simp only [Measure.ae, MeasurableSet.compl_iff, EventuallyEq, Filter.Eventually,
             Pi.zero_apply, Filter.mem_mk, mem_setOf_eq]
lemma ae_restrict_eq_const_iff_ae_eq_const_of_mem {E : Type*} [MeasurableSpace E]
    [MeasurableSingletonClass E] {f : α → E} (c : E) {s : Set α}
    (f_mble : NullMeasurable f (μ.restrict s)) :
    f =ᵐ[Measure.restrict μ s] (fun _ ↦ c) ↔ ∀ᵐ x ∂μ, x ∈ s → f x = c := by
  simp only [Measure.ae, MeasurableSet.compl_iff, EventuallyEq, Filter.Eventually,
             Pi.zero_apply, Filter.mem_mk, mem_setOf_eq]
  

Proof state:
α : Type u_1
β : Type u_2
E✝ : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E✝
f✝ g : α → E✝
s✝ t : Set α
μ ν : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E✝
E : Type u_5
inst✝¹ : MeasurableSpace E
inst✝ : MeasurableSingletonClass E
f : α → E
c : E
s : Set α
f_mble : NullMeasurable f
⊢ ↑↑(Measure.restrict μ s) {x | f x = c}ᶜ = 0 ↔ ↑↑μ {x | x ∈ s → f x = c}ᶜ = 0

Next tactic:
rw [Measure.restrict_apply₀]
lemma ae_restrict_eq_const_iff_ae_eq_const_of_mem {E : Type*} [MeasurableSpace E]
    [MeasurableSingletonClass E] {f : α → E} (c : E) {s : Set α}
    (f_mble : NullMeasurable f (μ.restrict s)) :
    f =ᵐ[Measure.restrict μ s] (fun _ ↦ c) ↔ ∀ᵐ x ∂μ, x ∈ s → f x = c := by
  simp only [Measure.ae, MeasurableSet.compl_iff, EventuallyEq, Filter.Eventually,
             Pi.zero_apply, Filter.mem_mk, mem_setOf_eq]
  rw [Measure.restrict_apply₀]
  · 

Proof state:
α : Type u_1
β : Type u_2
E✝ : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E✝
f✝ g : α → E✝
s✝ t : Set α
μ ν : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E✝
E : Type u_5
inst✝¹ : MeasurableSpace E
inst✝ : MeasurableSingletonClass E
f : α → E
c : E
s : Set α
f_mble : NullMeasurable f
⊢ ↑↑μ ({x | f x = c}ᶜ ∩ s) = 0 ↔ ↑↑μ {x | x ∈ s → f x = c}ᶜ = 0

Next tactic:
constructor