l3lab/ntp-mathlib huggingface dataset:
/-- To prove something for an arbitrary simple function, it suffices to show
that the property holds for (multiples of) characteristic functions and is closed under
addition (of functions with disjoint support).

It is possible to make the hypotheses in `h_add` a bit stronger, and such conditions can be added
once we need them (for example it is only necessary to consider the case where `g` is a multiple
of a characteristic function, and that this multiple doesn't appear in the image of `f`) -/
@[elab_as_elim]
protected theorem induction {α γ} [MeasurableSpace α] [AddMonoid γ] {P : SimpleFunc α γ → Prop}
    (h_ind :
      ∀ (c) {s} (hs : MeasurableSet s),
        P (SimpleFunc.piecewise s hs (SimpleFunc.const _ c) (SimpleFunc.const _ 0)))
    (h_add : ∀ ⦃f g : SimpleFunc α γ⦄, Disjoint (support f) (support g) → P f → P g → P (f + g))
    (f : SimpleFunc α γ) : P f := by
  generalize h : f.range \ {0} = s
  rw [← Finset.coe_inj, Finset.coe_sdiff, Finset.coe_singleton, SimpleFunc.coe_range] at h
  induction s using Finset.induction generalizing f with
  | empty =>
    rw [Finset.coe_empty, diff_eq_empty, range_subset_singleton] at h
    convert h_ind 0 MeasurableSet.univ
    ext x
    simp [h]
  | @insert x s hxs ih =>
    have mx := f.measurableSet_preimage {x}
    let g := SimpleFunc.piecewise (f ⁻¹' {x}) mx 0 f
    have Pg : P g := by
      apply ih
      simp only [SimpleFunc.coe_piecewise, range_piecewise]
      rw [image_compl_preimage, union_diff_distrib, diff_diff_comm, h, Finset.coe_insert,
        insert_diff_self_of_not_mem, diff_eq_empty.mpr, Set.empty_union]
      · rw [Set.image_subset_iff]
        convert Set.subset_univ _
        exact preimage_const_of_mem (mem_singleton _)
      · rwa [Finset.mem_coe]
    convert h_add _ Pg (h_ind x mx)
    · ext1 y
      by_cases hy : y ∈ f ⁻¹' {x}
      · simpa [piecewise_eq_of_mem _ _ _ hy, -piecewise_eq_indicator]
      · simp [piecewise_eq_of_not_mem _ _ _ hy, -piecewise_eq_indicator]
    rw [disjoint_iff_inf_le]
    

Proof state:
case insert
α✝ : Type u_1
β : Type u_2
γ✝ : Type u_3
δ : Type u_4
α : Type u_5
γ : Type u_6
inst✝¹ : MeasurableSpace α
inst✝ : AddMonoid γ
P : (α →ₛ γ) → Prop
h_ind : ∀ (c : γ) {s : Set α} (hs : MeasurableSet s), P (piecewise s hs (const α c) (const α 0))
h_add : ∀ ⦃f g : α →ₛ γ⦄, Disjoint (support ↑f) (support ↑g) → P f → P g → P (f + g)
x : γ
s : Finset γ
hxs : x ∉ s
ih : ∀ (f : α →ₛ γ), range ↑f \ {0} = ↑s → P f
f : α →ₛ γ
h : range ↑f \ {0} = ↑(insert x s)
mx : MeasurableSet (↑f ⁻¹' {x})
g : α →ₛ γ := piecewise (↑f ⁻¹' {x}) mx 0 f
Pg : P g
⊢ support ↑g ⊓ support ↑(piecewise (↑f ⁻¹' {x}) mx (const α x) (const α 0)) ≤ ⊥

Next tactic:
rintro y
/-- To prove something for an arbitrary simple function, it suffices to show
that the property holds for (multiples of) characteristic functions and is closed under
addition (of functions with disjoint support).

It is possible to make the hypotheses in `h_add` a bit stronger, and such conditions can be added
once we need them (for example it is only necessary to consider the case where `g` is a multiple
of a characteristic function, and that this multiple doesn't appear in the image of `f`) -/
@[elab_as_elim]
protected theorem induction {α γ} [MeasurableSpace α] [AddMonoid γ] {P : SimpleFunc α γ → Prop}
    (h_ind :
      ∀ (c) {s} (hs : MeasurableSet s),
        P (SimpleFunc.piecewise s hs (SimpleFunc.const _ c) (SimpleFunc.const _ 0)))
    (h_add : ∀ ⦃f g : SimpleFunc α γ⦄, Disjoint (support f) (support g) → P f → P g → P (f + g))
    (f : SimpleFunc α γ) : P f := by
  generalize h : f.range \ {0} = s
  rw [← Finset.coe_inj, Finset.coe_sdiff, Finset.coe_singleton, SimpleFunc.coe_range] at h
  induction s using Finset.induction generalizing f with
  | empty =>
    rw [Finset.coe_empty, diff_eq_empty, range_subset_singleton] at h
    convert h_ind 0 MeasurableSet.univ
    ext x
    simp [h]
  | @insert x s hxs ih =>
    have mx := f.measurableSet_preimage {x}
    let g := SimpleFunc.piecewise (f ⁻¹' {x}) mx 0 f
    have Pg : P g := by
      apply ih
      simp only [SimpleFunc.coe_piecewise, range_piecewise]
      rw [image_compl_preimage, union_diff_distrib, diff_diff_comm, h, Finset.coe_insert,
        insert_diff_self_of_not_mem, diff_eq_empty.mpr, Set.empty_union]
      · rw [Set.image_subset_iff]
        convert Set.subset_univ _
        exact preimage_const_of_mem (mem_singleton _)
      · rwa [Finset.mem_coe]
    convert h_add _ Pg (h_ind x mx)
    · ext1 y
      by_cases hy : y ∈ f ⁻¹' {x}
      · simpa [piecewise_eq_of_mem _ _ _ hy, -piecewise_eq_indicator]
      · simp [piecewise_eq_of_not_mem _ _ _ hy, -piecewise_eq_indicator]
    rw [disjoint_iff_inf_le]
    rintro y
    

Proof state:
case insert
α✝ : Type u_1
β : Type u_2
γ✝ : Type u_3
δ : Type u_4
α : Type u_5
γ : Type u_6
inst✝¹ : MeasurableSpace α
inst✝ : AddMonoid γ
P : (α →ₛ γ) → Prop
h_ind : ∀ (c : γ) {s : Set α} (hs : MeasurableSet s), P (piecewise s hs (const α c) (const α 0))
h_add : ∀ ⦃f g : α →ₛ γ⦄, Disjoint (support ↑f) (support ↑g) → P f → P g → P (f + g)
x : γ
s : Finset γ
hxs : x ∉ s
ih : ∀ (f : α →ₛ γ), range ↑f \ {0} = ↑s → P f
f : α →ₛ γ
h : range ↑f \ {0} = ↑(insert x s)
mx : MeasurableSet (↑f ⁻¹' {x})
g : α →ₛ γ := piecewise (↑f ⁻¹' {x}) mx 0 f
Pg : P g
y : α
⊢ y ∈ support ↑g ⊓ support ↑(piecewise (↑f ⁻¹' {x}) mx (const α x) (const α 0)) → y ∈ ⊥

Next tactic:
by_cases hy : y ∈ f ⁻¹' {x}
/-- To prove something for an arbitrary simple function, it suffices to show
that the property holds for (multiples of) characteristic functions and is closed under
addition (of functions with disjoint support).

It is possible to make the hypotheses in `h_add` a bit stronger, and such conditions can be added
once we need them (for example it is only necessary to consider the case where `g` is a multiple
of a characteristic function, and that this multiple doesn't appear in the image of `f`) -/
@[elab_as_elim]
protected theorem induction {α γ} [MeasurableSpace α] [AddMonoid γ] {P : SimpleFunc α γ → Prop}
    (h_ind :
      ∀ (c) {s} (hs : MeasurableSet s),
        P (SimpleFunc.piecewise s hs (SimpleFunc.const _ c) (SimpleFunc.const _ 0)))
    (h_add : ∀ ⦃f g : SimpleFunc α γ⦄, Disjoint (support f) (support g) → P f → P g → P (f + g))
    (f : SimpleFunc α γ) : P f := by
  generalize h : f.range \ {0} = s
  rw [← Finset.coe_inj, Finset.coe_sdiff, Finset.coe_singleton, SimpleFunc.coe_range] at h
  induction s using Finset.induction generalizing f with
  | empty =>
    rw [Finset.coe_empty, diff_eq_empty, range_subset_singleton] at h
    convert h_ind 0 MeasurableSet.univ
    ext x
    simp [h]
  | @insert x s hxs ih =>
    have mx := f.measurableSet_preimage {x}
    let g := SimpleFunc.piecewise (f ⁻¹' {x}) mx 0 f
    have Pg : P g := by
      apply ih
      simp only [SimpleFunc.coe_piecewise, range_piecewise]
      rw [image_compl_preimage, union_diff_distrib, diff_diff_comm, h, Finset.coe_insert,
        insert_diff_self_of_not_mem, diff_eq_empty.mpr, Set.empty_union]
      · rw [Set.image_subset_iff]
        convert Set.subset_univ _
        exact preimage_const_of_mem (mem_singleton _)
      · rwa [Finset.mem_coe]
    convert h_add _ Pg (h_ind x mx)
    · ext1 y
      by_cases hy : y ∈ f ⁻¹' {x}
      · simpa [piecewise_eq_of_mem _ _ _ hy, -piecewise_eq_indicator]
      · simp [piecewise_eq_of_not_mem _ _ _ hy, -piecewise_eq_indicator]
    rw [disjoint_iff_inf_le]
    rintro y
    by_cases hy : y ∈ f ⁻¹' {x}
    · 

Proof state:
case pos
α✝ : Type u_1
β : Type u_2
γ✝ : Type u_3
δ : Type u_4
α : Type u_5
γ : Type u_6
inst✝¹ : MeasurableSpace α
inst✝ : AddMonoid γ
P : (α →ₛ γ) → Prop
h_ind : ∀ (c : γ) {s : Set α} (hs : MeasurableSet s), P (piecewise s hs (const α c) (const α 0))
h_add : ∀ ⦃f g : α →ₛ γ⦄, Disjoint (support ↑f) (support ↑g) → P f → P g → P (f + g)
x : γ
s : Finset γ
hxs : x ∉ s
ih : ∀ (f : α →ₛ γ), range ↑f \ {0} = ↑s → P f
f : α →ₛ γ
h : range ↑f \ {0} = ↑(insert x s)
mx : MeasurableSet (↑f ⁻¹' {x})
g : α →ₛ γ := piecewise (↑f ⁻¹' {x}) mx 0 f
Pg : P g
y : α
hy : y ∈ ↑f ⁻¹' {x}
⊢ y ∈ support ↑g ⊓ support ↑(piecewise (↑f ⁻¹' {x}) mx (const α x) (const α 0)) → y ∈ ⊥

Next tactic:
simp [piecewise_eq_of_mem _ _ _ hy, -piecewise_eq_indicator]
/-- To prove something for an arbitrary simple function, it suffices to show
that the property holds for (multiples of) characteristic functions and is closed under
addition (of functions with disjoint support).

It is possible to make the hypotheses in `h_add` a bit stronger, and such conditions can be added
once we need them (for example it is only necessary to consider the case where `g` is a multiple
of a characteristic function, and that this multiple doesn't appear in the image of `f`) -/
@[elab_as_elim]
protected theorem induction {α γ} [MeasurableSpace α] [AddMonoid γ] {P : SimpleFunc α γ → Prop}
    (h_ind :
      ∀ (c) {s} (hs : MeasurableSet s),
        P (SimpleFunc.piecewise s hs (SimpleFunc.const _ c) (SimpleFunc.const _ 0)))
    (h_add : ∀ ⦃f g : SimpleFunc α γ⦄, Disjoint (support f) (support g) → P f → P g → P (f + g))
    (f : SimpleFunc α γ) : P f := by
  generalize h : f.range \ {0} = s
  rw [← Finset.coe_inj, Finset.coe_sdiff, Finset.coe_singleton, SimpleFunc.coe_range] at h
  induction s using Finset.induction generalizing f with
  | empty =>
    rw [Finset.coe_empty, diff_eq_empty, range_subset_singleton] at h
    convert h_ind 0 MeasurableSet.univ
    ext x
    simp [h]
  | @insert x s hxs ih =>
    have mx := f.measurableSet_preimage {x}
    let g := SimpleFunc.piecewise (f ⁻¹' {x}) mx 0 f
    have Pg : P g := by
      apply ih
      simp only [SimpleFunc.coe_piecewise, range_piecewise]
      rw [image_compl_preimage, union_diff_distrib, diff_diff_comm, h, Finset.coe_insert,
        insert_diff_self_of_not_mem, diff_eq_empty.mpr, Set.empty_union]
      · rw [Set.image_subset_iff]
        convert Set.subset_univ _
        exact preimage_const_of_mem (mem_singleton _)
      · rwa [Finset.mem_coe]
    convert h_add _ Pg (h_ind x mx)
    · ext1 y
      by_cases hy : y ∈ f ⁻¹' {x}
      · simpa [piecewise_eq_of_mem _ _ _ hy, -piecewise_eq_indicator]
      · simp [piecewise_eq_of_not_mem _ _ _ hy, -piecewise_eq_indicator]
    rw [disjoint_iff_inf_le]
    rintro y
    by_cases hy : y ∈ f ⁻¹' {x}
    · simp [piecewise_eq_of_mem _ _ _ hy, -piecewise_eq_indicator]
    · 

Proof state:
case neg
α✝ : Type u_1
β : Type u_2
γ✝ : Type u_3
δ : Type u_4
α : Type u_5
γ : Type u_6
inst✝¹ : MeasurableSpace α
inst✝ : AddMonoid γ
P : (α →ₛ γ) → Prop
h_ind : ∀ (c : γ) {s : Set α} (hs : MeasurableSet s), P (piecewise s hs (const α c) (const α 0))
h_add : ∀ ⦃f g : α →ₛ γ⦄, Disjoint (support ↑f) (support ↑g) → P f → P g → P (f + g)
x : γ
s : Finset γ
hxs : x ∉ s
ih : ∀ (f : α →ₛ γ), range ↑f \ {0} = ↑s → P f
f : α →ₛ γ
h : range ↑f \ {0} = ↑(insert x s)
mx : MeasurableSet (↑f ⁻¹' {x})
g : α →ₛ γ := piecewise (↑f ⁻¹' {x}) mx 0 f
Pg : P g
y : α
hy : y ∉ ↑f ⁻¹' {x}
⊢ y ∈ support ↑g ⊓ support ↑(piecewise (↑f ⁻¹' {x}) mx (const α x) (const α 0)) → y ∈ ⊥

Next tactic:
simp [piecewise_eq_of_not_mem _ _ _ hy, -piecewise_eq_indicator]
/-- In a topological vector space, the addition of a measurable function and a simple function is
measurable. -/
theorem _root_.Measurable.add_simpleFunc
    {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddGroup E] [MeasurableAdd E]
    {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) :
    Measurable (g + (f : α → E)) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
E : Type u_5
x✝ : MeasurableSpace α
inst✝² : MeasurableSpace E
inst✝¹ : AddGroup E
inst✝ : MeasurableAdd E
g : α → E
hg : Measurable g
f : α →ₛ E
⊢ Measurable (g + ↑f)

Next tactic:
classical
  induction' f using SimpleFunc.induction with c s hs f f' hff' hf hf'
  · simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero]
    change Measurable (g + s.piecewise (Function.const α c) (0 : α → E))
    rw [← s.piecewise_same g, ← piecewise_add]
    exact Measurable.piecewise hs (hg.add_const _) (hg.add_const _)
  · have : (g + ↑(f + f'))
        = (Function.support f).piecewise (g + (f : α → E)) (g + f') := by
      ext x
      by_cases hx : x ∈ Function.support f
      · simpa only [SimpleFunc.coe_add, Pi.add_apply, Function.mem_support, ne_eq, not_not,
          Set.piecewise_eq_of_mem _ _ _ hx, _root_.add_right_inj, add_right_eq_self]
          using Set.disjoint_left.1 hff' hx
      · simpa only [SimpleFunc.coe_add, Pi.add_apply, Function.mem_support, ne_eq, not_not,
          Set.piecewise_eq_of_not_mem _ _ _ hx, _root_.add_right_inj, add_left_eq_self] using hx
    rw [this]
    exact Measurable.piecewise f.measurableSet_support hf hf'
/-- In a topological vector space, the addition of a measurable function and a simple function is
measurable. -/
theorem _root_.Measurable.add_simpleFunc
    {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddGroup E] [MeasurableAdd E]
    {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) :
    Measurable (g + (f : α → E)) := by
  classical
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
E : Type u_5
x✝ : MeasurableSpace α
inst✝² : MeasurableSpace E
inst✝¹ : AddGroup E
inst✝ : MeasurableAdd E
g : α → E
hg : Measurable g
f : α →ₛ E
⊢ Measurable (g + ↑f)

Next tactic:
induction' f using SimpleFunc.induction with c s hs f f' hff' hf hf'
/-- In a topological vector space, the addition of a measurable function and a simple function is
measurable. -/
theorem _root_.Measurable.add_simpleFunc
    {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddGroup E] [MeasurableAdd E]
    {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) :
    Measurable (g + (f : α → E)) := by
  classical
  induction' f using SimpleFunc.induction with c s hs f f' hff' hf hf'
  · 

Proof state:
case h_ind
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
E : Type u_5
x✝ : MeasurableSpace α
inst✝² : MeasurableSpace E
inst✝¹ : AddGroup E
inst✝ : MeasurableAdd E
g : α → E
hg : Measurable g
c : E
s : Set α
hs : MeasurableSet s
⊢ Measurable (g + ↑(piecewise s hs (const α c) (const α 0)))

Next tactic:
simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero]
/-- In a topological vector space, the addition of a measurable function and a simple function is
measurable. -/
theorem _root_.Measurable.add_simpleFunc
    {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddGroup E] [MeasurableAdd E]
    {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) :
    Measurable (g + (f : α → E)) := by
  classical
  induction' f using SimpleFunc.induction with c s hs f f' hff' hf hf'
  · simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero]
    

Proof state:
case h_ind
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
E : Type u_5
x✝ : MeasurableSpace α
inst✝² : MeasurableSpace E
inst✝¹ : AddGroup E
inst✝ : MeasurableAdd E
g : α → E
hg : Measurable g
c : E
s : Set α
hs : MeasurableSet s
⊢ Measurable (g + Set.piecewise s (Function.const α c) 0)

Next tactic:
change Measurable (g + s.piecewise (Function.const α c) (0 : α → E))
/-- In a topological vector space, the addition of a measurable function and a simple function is
measurable. -/
theorem _root_.Measurable.add_simpleFunc
    {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddGroup E] [MeasurableAdd E]
    {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) :
    Measurable (g + (f : α → E)) := by
  classical
  induction' f using SimpleFunc.induction with c s hs f f' hff' hf hf'
  · simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero]
    change Measurable (g + s.piecewise (Function.const α c) (0 : α → E))
    

Proof state:
case h_ind
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
E : Type u_5
x✝ : MeasurableSpace α
inst✝² : MeasurableSpace E
inst✝¹ : AddGroup E
inst✝ : MeasurableAdd E
g : α → E
hg : Measurable g
c : E
s : Set α
hs : MeasurableSet s
⊢ Measurable (g + Set.piecewise s (Function.const α c) 0)

Next tactic:
rw [← s.piecewise_same g, ← piecewise_add]
/-- In a topological vector space, the addition of a measurable function and a simple function is
measurable. -/
theorem _root_.Measurable.add_simpleFunc
    {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddGroup E] [MeasurableAdd E]
    {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) :
    Measurable (g + (f : α → E)) := by
  classical
  induction' f using SimpleFunc.induction with c s hs f f' hff' hf hf'
  · simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero]
    change Measurable (g + s.piecewise (Function.const α c) (0 : α → E))
    rw [← s.piecewise_same g, ← piecewise_add]
    

Proof state:
case h_ind
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
E : Type u_5
x✝ : MeasurableSpace α
inst✝² : MeasurableSpace E
inst✝¹ : AddGroup E
inst✝ : MeasurableAdd E
g : α → E
hg : Measurable g
c : E
s : Set α
hs : MeasurableSet s
⊢ Measurable (Set.piecewise s (g + Function.const α c) (g + 0))

Next tactic:
exact Measurable.piecewise hs (hg.add_const _) (hg.add_const _)
/-- In a topological vector space, the addition of a measurable function and a simple function is
measurable. -/
theorem _root_.Measurable.add_simpleFunc
    {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddGroup E] [MeasurableAdd E]
    {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) :
    Measurable (g + (f : α → E)) := by
  classical
  induction' f using SimpleFunc.induction with c s hs f f' hff' hf hf'
  · simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero]
    change Measurable (g + s.piecewise (Function.const α c) (0 : α → E))
    rw [← s.piecewise_same g, ← piecewise_add]
    exact Measurable.piecewise hs (hg.add_const _) (hg.add_const _)
  · 

Proof state:
case h_add
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
E : Type u_5
x✝ : MeasurableSpace α
inst✝² : MeasurableSpace E
inst✝¹ : AddGroup E
inst✝ : MeasurableAdd E
g : α → E
hg : Measurable g
f f' : α →ₛ E
hff' : Disjoint (support ↑f) (support ↑f')
hf : Measurable (g + ↑f)
hf' : Measurable (g + ↑f')
⊢ Measurable (g + ↑(f + f'))

Next tactic:
have : (g + ↑(f + f'))
        = (Function.support f).piecewise (g + (f : α → E)) (g + f') := by
      ext x
      by_cases hx : x ∈ Function.support f
      · simpa only [SimpleFunc.coe_add, Pi.add_apply, Function.mem_support, ne_eq, not_not,
          Set.piecewise_eq_of_mem _ _ _ hx, _root_.add_right_inj, add_right_eq_self]
          using Set.disjoint_left.1 hff' hx
      · simpa only [SimpleFunc.coe_add, Pi.add_apply, Function.mem_support, ne_eq, not_not,
          Set.piecewise_eq_of_not_mem _ _ _ hx, _root_.add_right_inj, add_left_eq_self] using hx
/-- In a topological vector space, the addition of a measurable function and a simple function is
measurable. -/
theorem _root_.Measurable.add_simpleFunc
    {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddGroup E] [MeasurableAdd E]
    {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) :
    Measurable (g + (f : α → E)) := by
  classical
  induction' f using SimpleFunc.induction with c s hs f f' hff' hf hf'
  · simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero]
    change Measurable (g + s.piecewise (Function.const α c) (0 : α → E))
    rw [← s.piecewise_same g, ← piecewise_add]
    exact Measurable.piecewise hs (hg.add_const _) (hg.add_const _)
  · have : (g + ↑(f + f'))
        = (Function.support f).piecewise (g + (f : α → E)) (g + f') := by
      

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
E : Type u_5
x✝ : MeasurableSpace α
inst✝² : MeasurableSpace E
inst✝¹ : AddGroup E
inst✝ : MeasurableAdd E
g : α → E
hg : Measurable g
f f' : α →ₛ E
hff' : Disjoint (support ↑f) (support ↑f')
hf : Measurable (g + ↑f)
hf' : Measurable (g + ↑f')
⊢ g + ↑(f + f') = Set.piecewise (support ↑f) (g + ↑f) (g + ↑f')

Next tactic:
ext x
/-- In a topological vector space, the addition of a measurable function and a simple function is
measurable. -/
theorem _root_.Measurable.add_simpleFunc
    {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddGroup E] [MeasurableAdd E]
    {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) :
    Measurable (g + (f : α → E)) := by
  classical
  induction' f using SimpleFunc.induction with c s hs f f' hff' hf hf'
  · simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero]
    change Measurable (g + s.piecewise (Function.const α c) (0 : α → E))
    rw [← s.piecewise_same g, ← piecewise_add]
    exact Measurable.piecewise hs (hg.add_const _) (hg.add_const _)
  · have : (g + ↑(f + f'))
        = (Function.support f).piecewise (g + (f : α → E)) (g + f') := by
      ext x
      

Proof state:
case h
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
E : Type u_5
x✝ : MeasurableSpace α
inst✝² : MeasurableSpace E
inst✝¹ : AddGroup E
inst✝ : MeasurableAdd E
g : α → E
hg : Measurable g
f f' : α →ₛ E
hff' : Disjoint (support ↑f) (support ↑f')
hf : Measurable (g + ↑f)
hf' : Measurable (g + ↑f')
x : α
⊢ (g + ↑(f + f')) x = Set.piecewise (support ↑f) (g + ↑f) (g + ↑f') x

Next tactic:
by_cases hx : x ∈ Function.support f
/-- In a topological vector space, the addition of a measurable function and a simple function is
measurable. -/
theorem _root_.Measurable.add_simpleFunc
    {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddGroup E] [MeasurableAdd E]
    {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) :
    Measurable (g + (f : α → E)) := by
  classical
  induction' f using SimpleFunc.induction with c s hs f f' hff' hf hf'
  · simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero]
    change Measurable (g + s.piecewise (Function.const α c) (0 : α → E))
    rw [← s.piecewise_same g, ← piecewise_add]
    exact Measurable.piecewise hs (hg.add_const _) (hg.add_const _)
  · have : (g + ↑(f + f'))
        = (Function.support f).piecewise (g + (f : α → E)) (g + f') := by
      ext x
      by_cases hx : x ∈ Function.support f
      · 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
E : Type u_5
x✝ : MeasurableSpace α
inst✝² : MeasurableSpace E
inst✝¹ : AddGroup E
inst✝ : MeasurableAdd E
g : α → E
hg : Measurable g
f f' : α →ₛ E
hff' : Disjoint (support ↑f) (support ↑f')
hf : Measurable (g + ↑f)
hf' : Measurable (g + ↑f')
x : α
hx : x ∈ support ↑f
⊢ (g + ↑(f + f')) x = Set.piecewise (support ↑f) (g + ↑f) (g + ↑f') x

Next tactic:
simpa only [SimpleFunc.coe_add, Pi.add_apply, Function.mem_support, ne_eq, not_not,
          Set.piecewise_eq_of_mem _ _ _ hx, _root_.add_right_inj, add_right_eq_self]
          using Set.disjoint_left.1 hff' hx