l3lab/ntp-mathlib huggingface dataset:
theorem eapprox_lt_top (f : α → ℝ≥0∞) (n : ℕ) (a : α) : eapprox f n a < ∞ := by
  simp only [eapprox, approx, finset_sup_apply, Finset.mem_range, ENNReal.bot_eq_zero, restrict]
  rw [Finset.sup_lt_iff (α := ℝ≥0∞) WithTop.zero_lt_top]
  intro b _
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
n : ℕ
a : α
b : ℕ
a✝ : b ∈ Finset.range n
⊢ ↑(if hs : MeasurableSet {a | ennrealRatEmbed b ≤ f a} then
          piecewise {a | ennrealRatEmbed b ≤ f a} hs (const α (ennrealRatEmbed b)) 0
        else 0)
      a <
    ⊤

Next tactic:
split_ifs
theorem eapprox_lt_top (f : α → ℝ≥0∞) (n : ℕ) (a : α) : eapprox f n a < ∞ := by
  simp only [eapprox, approx, finset_sup_apply, Finset.mem_range, ENNReal.bot_eq_zero, restrict]
  rw [Finset.sup_lt_iff (α := ℝ≥0∞) WithTop.zero_lt_top]
  intro b _
  split_ifs
  · 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
n : ℕ
a : α
b : ℕ
a✝ : b ∈ Finset.range n
h✝ : MeasurableSet {a | ennrealRatEmbed b ≤ f a}
⊢ ↑(piecewise {a | ennrealRatEmbed b ≤ f a} h✝ (const α (ennrealRatEmbed b)) 0) a < ⊤

Next tactic:
simp only [coe_zero, coe_piecewise, piecewise_eq_indicator, coe_const]
theorem eapprox_lt_top (f : α → ℝ≥0∞) (n : ℕ) (a : α) : eapprox f n a < ∞ := by
  simp only [eapprox, approx, finset_sup_apply, Finset.mem_range, ENNReal.bot_eq_zero, restrict]
  rw [Finset.sup_lt_iff (α := ℝ≥0∞) WithTop.zero_lt_top]
  intro b _
  split_ifs
  · simp only [coe_zero, coe_piecewise, piecewise_eq_indicator, coe_const]
    

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
n : ℕ
a : α
b : ℕ
a✝ : b ∈ Finset.range n
h✝ : MeasurableSet {a | ennrealRatEmbed b ≤ f a}
⊢ Set.piecewise {a | ennrealRatEmbed b ≤ f a} (Function.const α (ennrealRatEmbed b)) 0 a < ⊤

Next tactic:
calc
      { a : α | ennrealRatEmbed b ≤ f a }.indicator (fun _ => ennrealRatEmbed b) a ≤
          ennrealRatEmbed b :=
        indicator_le_self _ _ a
      _ < ⊤ := ENNReal.coe_lt_top
theorem eapprox_lt_top (f : α → ℝ≥0∞) (n : ℕ) (a : α) : eapprox f n a < ∞ := by
  simp only [eapprox, approx, finset_sup_apply, Finset.mem_range, ENNReal.bot_eq_zero, restrict]
  rw [Finset.sup_lt_iff (α := ℝ≥0∞) WithTop.zero_lt_top]
  intro b _
  split_ifs
  · simp only [coe_zero, coe_piecewise, piecewise_eq_indicator, coe_const]
    calc
      { a : α | ennrealRatEmbed b ≤ f a }.indicator (fun _ => ennrealRatEmbed b) a ≤
          ennrealRatEmbed b :=
        indicator_le_self _ _ a
      _ < ⊤ := ENNReal.coe_lt_top
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
n : ℕ
a : α
b : ℕ
a✝ : b ∈ Finset.range n
h✝ : ¬MeasurableSet {a | ennrealRatEmbed b ≤ f a}
⊢ ↑0 a < ⊤

Next tactic:
exact WithTop.zero_lt_top
theorem iSup_eapprox_apply (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) :
    ⨆ n, (eapprox f n : α →ₛ ℝ≥0∞) a = f a := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
hf : Measurable f
a : α
⊢ ⨆ n, ↑(eapprox f n) a = f a

Next tactic:
rw [eapprox, iSup_approx_apply ennrealRatEmbed f a hf rfl]
theorem iSup_eapprox_apply (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) :
    ⨆ n, (eapprox f n : α →ₛ ℝ≥0∞) a = f a := by
  rw [eapprox, iSup_approx_apply ennrealRatEmbed f a hf rfl]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
hf : Measurable f
a : α
⊢ ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k = f a

Next tactic:
refine' le_antisymm (iSup_le fun i => iSup_le fun hi => hi) (le_of_not_gt _)
theorem iSup_eapprox_apply (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) :
    ⨆ n, (eapprox f n : α →ₛ ℝ≥0∞) a = f a := by
  rw [eapprox, iSup_approx_apply ennrealRatEmbed f a hf rfl]
  refine' le_antisymm (iSup_le fun i => iSup_le fun hi => hi) (le_of_not_gt _)
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
hf : Measurable f
a : α
⊢ ¬f a > ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k

Next tactic:
intro h
theorem iSup_eapprox_apply (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) :
    ⨆ n, (eapprox f n : α →ₛ ℝ≥0∞) a = f a := by
  rw [eapprox, iSup_approx_apply ennrealRatEmbed f a hf rfl]
  refine' le_antisymm (iSup_le fun i => iSup_le fun hi => hi) (le_of_not_gt _)
  intro h
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
hf : Measurable f
a : α
h : f a > ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k
⊢ False

Next tactic:
rcases ENNReal.lt_iff_exists_rat_btwn.1 h with ⟨q, _, lt_q, q_lt⟩
theorem iSup_eapprox_apply (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) :
    ⨆ n, (eapprox f n : α →ₛ ℝ≥0∞) a = f a := by
  rw [eapprox, iSup_approx_apply ennrealRatEmbed f a hf rfl]
  refine' le_antisymm (iSup_le fun i => iSup_le fun hi => hi) (le_of_not_gt _)
  intro h
  rcases ENNReal.lt_iff_exists_rat_btwn.1 h with ⟨q, _, lt_q, q_lt⟩
  

Proof state:
case intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
hf : Measurable f
a : α
h : f a > ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k
q : ℚ
left✝ : 0 ≤ q
lt_q : ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k < ↑(Real.toNNReal ↑q)
q_lt : ↑(Real.toNNReal ↑q) < f a
⊢ False

Next tactic:
have :
    (Real.toNNReal q : ℝ≥0∞) ≤ ⨆ (k : ℕ) (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k := by
    refine' le_iSup_of_le (Encodable.encode q) _
    rw [ennrealRatEmbed_encode q]
    exact le_iSup_of_le (le_of_lt q_lt) le_rfl
theorem iSup_eapprox_apply (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) :
    ⨆ n, (eapprox f n : α →ₛ ℝ≥0∞) a = f a := by
  rw [eapprox, iSup_approx_apply ennrealRatEmbed f a hf rfl]
  refine' le_antisymm (iSup_le fun i => iSup_le fun hi => hi) (le_of_not_gt _)
  intro h
  rcases ENNReal.lt_iff_exists_rat_btwn.1 h with ⟨q, _, lt_q, q_lt⟩
  have :
    (Real.toNNReal q : ℝ≥0∞) ≤ ⨆ (k : ℕ) (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k := by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
hf : Measurable f
a : α
h : f a > ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k
q : ℚ
left✝ : 0 ≤ q
lt_q : ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k < ↑(Real.toNNReal ↑q)
q_lt : ↑(Real.toNNReal ↑q) < f a
⊢ ↑(Real.toNNReal ↑q) ≤ ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k

Next tactic:
refine' le_iSup_of_le (Encodable.encode q) _
theorem iSup_eapprox_apply (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) :
    ⨆ n, (eapprox f n : α →ₛ ℝ≥0∞) a = f a := by
  rw [eapprox, iSup_approx_apply ennrealRatEmbed f a hf rfl]
  refine' le_antisymm (iSup_le fun i => iSup_le fun hi => hi) (le_of_not_gt _)
  intro h
  rcases ENNReal.lt_iff_exists_rat_btwn.1 h with ⟨q, _, lt_q, q_lt⟩
  have :
    (Real.toNNReal q : ℝ≥0∞) ≤ ⨆ (k : ℕ) (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k := by
    refine' le_iSup_of_le (Encodable.encode q) _
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
hf : Measurable f
a : α
h : f a > ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k
q : ℚ
left✝ : 0 ≤ q
lt_q : ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k < ↑(Real.toNNReal ↑q)
q_lt : ↑(Real.toNNReal ↑q) < f a
⊢ ↑(Real.toNNReal ↑q) ≤ ⨆ (_ : ennrealRatEmbed (Encodable.encode q) ≤ f a), ennrealRatEmbed (Encodable.encode q)

Next tactic:
rw [ennrealRatEmbed_encode q]
theorem iSup_eapprox_apply (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) :
    ⨆ n, (eapprox f n : α →ₛ ℝ≥0∞) a = f a := by
  rw [eapprox, iSup_approx_apply ennrealRatEmbed f a hf rfl]
  refine' le_antisymm (iSup_le fun i => iSup_le fun hi => hi) (le_of_not_gt _)
  intro h
  rcases ENNReal.lt_iff_exists_rat_btwn.1 h with ⟨q, _, lt_q, q_lt⟩
  have :
    (Real.toNNReal q : ℝ≥0∞) ≤ ⨆ (k : ℕ) (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k := by
    refine' le_iSup_of_le (Encodable.encode q) _
    rw [ennrealRatEmbed_encode q]
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
hf : Measurable f
a : α
h : f a > ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k
q : ℚ
left✝ : 0 ≤ q
lt_q : ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k < ↑(Real.toNNReal ↑q)
q_lt : ↑(Real.toNNReal ↑q) < f a
⊢ ↑(Real.toNNReal ↑q) ≤ ⨆ (_ : ↑(Real.toNNReal ↑q) ≤ f a), ↑(Real.toNNReal ↑q)

Next tactic:
exact le_iSup_of_le (le_of_lt q_lt) le_rfl
theorem iSup_eapprox_apply (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) :
    ⨆ n, (eapprox f n : α →ₛ ℝ≥0∞) a = f a := by
  rw [eapprox, iSup_approx_apply ennrealRatEmbed f a hf rfl]
  refine' le_antisymm (iSup_le fun i => iSup_le fun hi => hi) (le_of_not_gt _)
  intro h
  rcases ENNReal.lt_iff_exists_rat_btwn.1 h with ⟨q, _, lt_q, q_lt⟩
  have :
    (Real.toNNReal q : ℝ≥0∞) ≤ ⨆ (k : ℕ) (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k := by
    refine' le_iSup_of_le (Encodable.encode q) _
    rw [ennrealRatEmbed_encode q]
    exact le_iSup_of_le (le_of_lt q_lt) le_rfl
  

Proof state:
case intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
hf : Measurable f
a : α
h : f a > ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k
q : ℚ
left✝ : 0 ≤ q
lt_q : ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k < ↑(Real.toNNReal ↑q)
q_lt : ↑(Real.toNNReal ↑q) < f a
this : ↑(Real.toNNReal ↑q) ≤ ⨆ k, ⨆ (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k
⊢ False

Next tactic:
exact lt_irrefl _ (lt_of_le_of_lt this lt_q)
theorem sum_eapproxDiff (f : α → ℝ≥0∞) (n : ℕ) (a : α) :
    (∑ k in Finset.range (n + 1), (eapproxDiff f k a : ℝ≥0∞)) = eapprox f n a := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
n : ℕ
a : α
⊢ ∑ k in Finset.range (n + 1), ↑(↑(eapproxDiff f k) a) = ↑(eapprox f n) a

Next tactic:
induction' n with n IH
theorem sum_eapproxDiff (f : α → ℝ≥0∞) (n : ℕ) (a : α) :
    (∑ k in Finset.range (n + 1), (eapproxDiff f k a : ℝ≥0∞)) = eapprox f n a := by
  induction' n with n IH
  · 

Proof state:
case zero
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
a : α
⊢ ∑ k in Finset.range (Nat.zero + 1), ↑(↑(eapproxDiff f k) a) = ↑(eapprox f Nat.zero) a

Next tactic:
simp only [Nat.zero_eq, Nat.zero_add, Finset.sum_singleton, Finset.range_one]
theorem sum_eapproxDiff (f : α → ℝ≥0∞) (n : ℕ) (a : α) :
    (∑ k in Finset.range (n + 1), (eapproxDiff f k a : ℝ≥0∞)) = eapprox f n a := by
  induction' n with n IH
  · simp only [Nat.zero_eq, Nat.zero_add, Finset.sum_singleton, Finset.range_one]
    

Proof state:
case zero
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
a : α
⊢ ↑(↑(eapproxDiff f 0) a) = ↑(eapprox f 0) a

Next tactic:
rfl
theorem sum_eapproxDiff (f : α → ℝ≥0∞) (n : ℕ) (a : α) :
    (∑ k in Finset.range (n + 1), (eapproxDiff f k a : ℝ≥0∞)) = eapprox f n a := by
  induction' n with n IH
  · simp only [Nat.zero_eq, Nat.zero_add, Finset.sum_singleton, Finset.range_one]
    rfl
  · 

Proof state:
case succ
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
a : α
n : ℕ
IH : ∑ k in Finset.range (n + 1), ↑(↑(eapproxDiff f k) a) = ↑(eapprox f n) a
⊢ ∑ k in Finset.range (Nat.succ n + 1), ↑(↑(eapproxDiff f k) a) = ↑(eapprox f (Nat.succ n)) a

Next tactic:
erw [Finset.sum_range_succ, Nat.succ_eq_add_one, IH, eapproxDiff, coe_map, Function.comp_apply,
      coe_sub, Pi.sub_apply, ENNReal.coe_toNNReal,
      add_tsub_cancel_of_le (monotone_eapprox f (Nat.le_succ _) _)]
theorem sum_eapproxDiff (f : α → ℝ≥0∞) (n : ℕ) (a : α) :
    (∑ k in Finset.range (n + 1), (eapproxDiff f k a : ℝ≥0∞)) = eapprox f n a := by
  induction' n with n IH
  · simp only [Nat.zero_eq, Nat.zero_add, Finset.sum_singleton, Finset.range_one]
    rfl
  · erw [Finset.sum_range_succ, Nat.succ_eq_add_one, IH, eapproxDiff, coe_map, Function.comp_apply,
      coe_sub, Pi.sub_apply, ENNReal.coe_toNNReal,
      add_tsub_cancel_of_le (monotone_eapprox f (Nat.le_succ _) _)]
    

Proof state:
case succ
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
a : α
n : ℕ
IH : ∑ k in Finset.range (n + 1), ↑(↑(eapproxDiff f k) a) = ↑(eapprox f n) a
⊢ ↑(eapprox f (Nat.add n 0 + 1)) a - ↑(eapprox f (Nat.add n 0)) a ≠ ⊤

Next tactic:
apply (lt_of_le_of_lt _ (eapprox_lt_top f (n + 1) a)).ne
theorem sum_eapproxDiff (f : α → ℝ≥0∞) (n : ℕ) (a : α) :
    (∑ k in Finset.range (n + 1), (eapproxDiff f k a : ℝ≥0∞)) = eapprox f n a := by
  induction' n with n IH
  · simp only [Nat.zero_eq, Nat.zero_add, Finset.sum_singleton, Finset.range_one]
    rfl
  · erw [Finset.sum_range_succ, Nat.succ_eq_add_one, IH, eapproxDiff, coe_map, Function.comp_apply,
      coe_sub, Pi.sub_apply, ENNReal.coe_toNNReal,
      add_tsub_cancel_of_le (monotone_eapprox f (Nat.le_succ _) _)]
    apply (lt_of_le_of_lt _ (eapprox_lt_top f (n + 1) a)).ne
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
a : α
n : ℕ
IH : ∑ k in Finset.range (n + 1), ↑(↑(eapproxDiff f k) a) = ↑(eapprox f n) a
⊢ ↑(eapprox f (Nat.add n 0 + 1)) a - ↑(eapprox f (Nat.add n 0)) a ≤ ↑(eapprox f (n + 1)) a

Next tactic:
rw [tsub_le_iff_right]
theorem sum_eapproxDiff (f : α → ℝ≥0∞) (n : ℕ) (a : α) :
    (∑ k in Finset.range (n + 1), (eapproxDiff f k a : ℝ≥0∞)) = eapprox f n a := by
  induction' n with n IH
  · simp only [Nat.zero_eq, Nat.zero_add, Finset.sum_singleton, Finset.range_one]
    rfl
  · erw [Finset.sum_range_succ, Nat.succ_eq_add_one, IH, eapproxDiff, coe_map, Function.comp_apply,
      coe_sub, Pi.sub_apply, ENNReal.coe_toNNReal,
      add_tsub_cancel_of_le (monotone_eapprox f (Nat.le_succ _) _)]
    apply (lt_of_le_of_lt _ (eapprox_lt_top f (n + 1) a)).ne
    rw [tsub_le_iff_right]
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
a : α
n : ℕ
IH : ∑ k in Finset.range (n + 1), ↑(↑(eapproxDiff f k) a) = ↑(eapprox f n) a
⊢ ↑(eapprox f (Nat.add n 0 + 1)) a ≤ ↑(eapprox f (n + 1)) a + ↑(eapprox f (Nat.add n 0)) a

Next tactic:
exact le_self_add
theorem tsum_eapproxDiff (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) :
    (∑' n, (eapproxDiff f n a : ℝ≥0∞)) = f a := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝ : MeasurableSpace α
K : Type u_5
f : α → ℝ≥0∞
hf : Measurable f
a : α
⊢ ∑' (n : ℕ), ↑(↑(eapproxDiff f n) a) = f a

Next tactic:
simp_rw [ENNReal.tsum_eq_iSup_nat' (tendsto_add_atTop_nat 1), sum_eapproxDiff,
    iSup_eapprox_apply f hf a]
theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞}
    (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) :
    f.lintegral μ = ∑ x in s, x * μ (f ⁻¹' {x}) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Finset ℝ≥0∞
hs : ∀ (x : α), ↑f x ≠ 0 → ↑↑μ (↑f ⁻¹' {↑f x}) ≠ 0 → ↑f x ∈ s
⊢ lintegral f μ = ∑ x in s, x * ↑↑μ (↑f ⁻¹' {x})

Next tactic:
refine' Finset.sum_bij_ne_zero (fun r _ _ => r) _ _ _ _
theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞}
    (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) :
    f.lintegral μ = ∑ x in s, x * μ (f ⁻¹' {x}) := by
  refine' Finset.sum_bij_ne_zero (fun r _ _ => r) _ _ _ _
  · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Finset ℝ≥0∞
hs : ∀ (x : α), ↑f x ≠ 0 → ↑↑μ (↑f ⁻¹' {↑f x}) ≠ 0 → ↑f x ∈ s
⊢ ∀ (a : ℝ≥0∞) (h₁ : a ∈ SimpleFunc.range f) (h₂ : a * ↑↑μ (↑f ⁻¹' {a}) ≠ 0), (fun r x x => r) a h₁ h₂ ∈ s

Next tactic:
simpa only [forall_range_iff, mul_ne_zero_iff, and_imp]
theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞}
    (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) :
    f.lintegral μ = ∑ x in s, x * μ (f ⁻¹' {x}) := by
  refine' Finset.sum_bij_ne_zero (fun r _ _ => r) _ _ _ _
  · simpa only [forall_range_iff, mul_ne_zero_iff, and_imp]
  · 

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

Next tactic:
intros
theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞}
    (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) :
    f.lintegral μ = ∑ x in s, x * μ (f ⁻¹' {x}) := by
  refine' Finset.sum_bij_ne_zero (fun r _ _ => r) _ _ _ _
  · simpa only [forall_range_iff, mul_ne_zero_iff, and_imp]
  · intros
    

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Finset ℝ≥0∞
hs : ∀ (x : α), ↑f x ≠ 0 → ↑↑μ (↑f ⁻¹' {↑f x}) ≠ 0 → ↑f x ∈ s
a₁✝ a₂✝ : ℝ≥0∞
h₁₁✝ : a₁✝ ∈ SimpleFunc.range f
h₁₂✝ : a₁✝ * ↑↑μ (↑f ⁻¹' {a₁✝}) ≠ 0
h₂₁✝ : a₂✝ ∈ SimpleFunc.range f
h₂₂✝ : a₂✝ * ↑↑μ (↑f ⁻¹' {a₂✝}) ≠ 0
a✝ : (fun r x x => r) a₁✝ h₁₁✝ h₁₂✝ = (fun r x x => r) a₂✝ h₂₁✝ h₂₂✝
⊢ a₁✝ = a₂✝

Next tactic:
assumption
theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞}
    (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) :
    f.lintegral μ = ∑ x in s, x * μ (f ⁻¹' {x}) := by
  refine' Finset.sum_bij_ne_zero (fun r _ _ => r) _ _ _ _
  · simpa only [forall_range_iff, mul_ne_zero_iff, and_imp]
  · intros
    assumption
  · 

Proof state:
case refine'_3
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Finset ℝ≥0∞
hs : ∀ (x : α), ↑f x ≠ 0 → ↑↑μ (↑f ⁻¹' {↑f x}) ≠ 0 → ↑f x ∈ s
⊢ ∀ b ∈ s,
    b * ↑↑μ (↑f ⁻¹' {b}) ≠ 0 →
      ∃ a, ∃ (h₁ : a ∈ SimpleFunc.range f) (h₂ : a * ↑↑μ (↑f ⁻¹' {a}) ≠ 0), b = (fun r x x => r) a h₁ h₂

Next tactic:
intro b _ hb
theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞}
    (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) :
    f.lintegral μ = ∑ x in s, x * μ (f ⁻¹' {x}) := by
  refine' Finset.sum_bij_ne_zero (fun r _ _ => r) _ _ _ _
  · simpa only [forall_range_iff, mul_ne_zero_iff, and_imp]
  · intros
    assumption
  · intro b _ hb
    

Proof state:
case refine'_3
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Finset ℝ≥0∞
hs : ∀ (x : α), ↑f x ≠ 0 → ↑↑μ (↑f ⁻¹' {↑f x}) ≠ 0 → ↑f x ∈ s
b : ℝ≥0∞
a✝ : b ∈ s
hb : b * ↑↑μ (↑f ⁻¹' {b}) ≠ 0
⊢ ∃ a, ∃ (h₁ : a ∈ SimpleFunc.range f) (h₂ : a * ↑↑μ (↑f ⁻¹' {a}) ≠ 0), b = (fun r x x => r) a h₁ h₂

Next tactic:
refine' ⟨b, _, hb, rfl⟩
theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞}
    (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) :
    f.lintegral μ = ∑ x in s, x * μ (f ⁻¹' {x}) := by
  refine' Finset.sum_bij_ne_zero (fun r _ _ => r) _ _ _ _
  · simpa only [forall_range_iff, mul_ne_zero_iff, and_imp]
  · intros
    assumption
  · intro b _ hb
    refine' ⟨b, _, hb, rfl⟩
    

Proof state:
case refine'_3
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Finset ℝ≥0∞
hs : ∀ (x : α), ↑f x ≠ 0 → ↑↑μ (↑f ⁻¹' {↑f x}) ≠ 0 → ↑f x ∈ s
b : ℝ≥0∞
a✝ : b ∈ s
hb : b * ↑↑μ (↑f ⁻¹' {b}) ≠ 0
⊢ b ∈ SimpleFunc.range f

Next tactic:
rw [mem_range, ← preimage_singleton_nonempty]
theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞}
    (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) :
    f.lintegral μ = ∑ x in s, x * μ (f ⁻¹' {x}) := by
  refine' Finset.sum_bij_ne_zero (fun r _ _ => r) _ _ _ _
  · simpa only [forall_range_iff, mul_ne_zero_iff, and_imp]
  · intros
    assumption
  · intro b _ hb
    refine' ⟨b, _, hb, rfl⟩
    rw [mem_range, ← preimage_singleton_nonempty]
    

Proof state:
case refine'_3
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Finset ℝ≥0∞
hs : ∀ (x : α), ↑f x ≠ 0 → ↑↑μ (↑f ⁻¹' {↑f x}) ≠ 0 → ↑f x ∈ s
b : ℝ≥0∞
a✝ : b ∈ s
hb : b * ↑↑μ (↑f ⁻¹' {b}) ≠ 0
⊢ Set.Nonempty (↑f ⁻¹' {b})

Next tactic:
exact nonempty_of_measure_ne_zero (mul_ne_zero_iff.1 hb).2
theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞}
    (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) :
    f.lintegral μ = ∑ x in s, x * μ (f ⁻¹' {x}) := by
  refine' Finset.sum_bij_ne_zero (fun r _ _ => r) _ _ _ _
  · simpa only [forall_range_iff, mul_ne_zero_iff, and_imp]
  · intros
    assumption
  · intro b _ hb
    refine' ⟨b, _, hb, rfl⟩
    rw [mem_range, ← preimage_singleton_nonempty]
    exact nonempty_of_measure_ne_zero (mul_ne_zero_iff.1 hb).2
  · 

Proof state:
case refine'_4
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Finset ℝ≥0∞
hs : ∀ (x : α), ↑f x ≠ 0 → ↑↑μ (↑f ⁻¹' {↑f x}) ≠ 0 → ↑f x ∈ s
⊢ ∀ (a : ℝ≥0∞) (h₁ : a ∈ SimpleFunc.range f) (h₂ : a * ↑↑μ (↑f ⁻¹' {a}) ≠ 0),
    a * ↑↑μ (↑f ⁻¹' {a}) = (fun r x x => r) a h₁ h₂ * ↑↑μ (↑f ⁻¹' {(fun r x x => r) a h₁ h₂})

Next tactic:
intros
theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞}
    (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) :
    f.lintegral μ = ∑ x in s, x * μ (f ⁻¹' {x}) := by
  refine' Finset.sum_bij_ne_zero (fun r _ _ => r) _ _ _ _
  · simpa only [forall_range_iff, mul_ne_zero_iff, and_imp]
  · intros
    assumption
  · intro b _ hb
    refine' ⟨b, _, hb, rfl⟩
    rw [mem_range, ← preimage_singleton_nonempty]
    exact nonempty_of_measure_ne_zero (mul_ne_zero_iff.1 hb).2
  · intros
    

Proof state:
case refine'_4
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m : MeasurableSpace α
μ ν : Measure α
f : α →ₛ ℝ≥0∞
s : Finset ℝ≥0∞
hs : ∀ (x : α), ↑f x ≠ 0 → ↑↑μ (↑f ⁻¹' {↑f x}) ≠ 0 → ↑f x ∈ s
a✝ : ℝ≥0∞
h₁✝ : a✝ ∈ SimpleFunc.range f
h₂✝ : a✝ * ↑↑μ (↑f ⁻¹' {a✝}) ≠ 0
⊢ a✝ * ↑↑μ (↑f ⁻¹' {a✝}) = (fun r x x => r) a✝ h₁✝ h₂✝ * ↑↑μ (↑f ⁻¹' {(fun r x x => r) a✝ h₁✝ h₂✝})

Next tactic:
rfl
/-- 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
  

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

Next tactic:
simp only [lintegral, range_map]
/-- 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]
  

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

Next tactic:
refine' Finset.sum_image' _ fun b hb => _
/-- 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 => _
  

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

Next tactic:
rcases mem_range.1 hb with ⟨a, rfl⟩