Theorem: integral_comp_abs
File: Mathlib/MeasureTheory/Measure/Lebesgue/Integral.lean

tactic: have eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x := by
  refine setIntegral_congr measurableSet_Ioi (fun _ hx => ?_)
  rw [abs_eq_self.mpr (le_of_lt (by exact hx))]
state_before: f : ℝ → ℝ
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x
state_after: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x

tactic: by_cases hf : IntegrableOn (fun x => f |x|) (Ioi 0)
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x
state_after: case pos
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x

case neg
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : ¬IntegrableOn (fun x => f |x|) (Ioi 0) volume
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x

tactic: refine setIntegral_congr measurableSet_Ioi (fun _ hx => ?_)
state_before: f : ℝ → ℝ
⊢ ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
state_after: f : ℝ → ℝ
x✝ : ℝ
hx : x✝ ∈ Ioi 0
⊢ f |x✝| = f x✝

tactic: rw [abs_eq_self.mpr (le_of_lt (by exact hx))]
state_before: f : ℝ → ℝ
x✝ : ℝ
hx : x✝ ∈ Ioi 0
⊢ f |x✝| = f x✝
state_after: no goals

tactic: exact hx
state_before: f : ℝ → ℝ
x✝ : ℝ
hx : x✝ ∈ Ioi 0
⊢ 0 < x✝
state_after: no goals

tactic: have int_Iic : IntegrableOn (fun x ↦ f |x|) (Iic 0) := by
  rw [← Measure.map_neg_eq_self (volume : Measure ℝ)]
  let m : MeasurableEmbedding fun x : ℝ => -x := (Homeomorph.neg ℝ).measurableEmbedding
  rw [m.integrableOn_map_iff]
  simp_rw [Function.comp, abs_neg, neg_preimage, preimage_neg_Iic, neg_zero]
  exact integrableOn_Ici_iff_integrableOn_Ioi.mpr hf
state_before: case pos
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x
state_after: case pos
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x

tactic: calc
  _ = (∫ x in Iic 0, f |x|) + ∫ x in Ioi 0, f |x| := by
    rw [← integral_union (Iic_disjoint_Ioi le_rfl) measurableSet_Ioi int_Iic hf,
      Iic_union_Ioi, restrict_univ]
  _ = 2 * ∫ x in Ioi 0, f x := by
    rw [two_mul, eq]
    congr! 1
    rw [← neg_zero, ← integral_comp_neg_Iic, neg_zero]
    refine setIntegral_congr measurableSet_Iic (fun _ hx => ?_)
    rw [abs_eq_neg_self.mpr (by exact hx)]
state_before: case pos
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x
state_after: no goals

tactic: rw [← Measure.map_neg_eq_self (volume : Measure ℝ)]
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
⊢ IntegrableOn (fun x => f |x|) (Iic 0) volume
state_after: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
⊢ IntegrableOn (fun x => f |x|) (Iic 0) (Measure.map Neg.neg volume)

tactic: let m : MeasurableEmbedding fun x : ℝ => -x := (Homeomorph.neg ℝ).measurableEmbedding
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
⊢ IntegrableOn (fun x => f |x|) (Iic 0) (Measure.map Neg.neg volume)
state_after: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
m : MeasurableEmbedding fun x => -x := Homeomorph.measurableEmbedding (Homeomorph.neg ℝ)
⊢ IntegrableOn (fun x => f |x|) (Iic 0) (Measure.map Neg.neg volume)

tactic: rw [m.integrableOn_map_iff]
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
m : MeasurableEmbedding fun x => -x := Homeomorph.measurableEmbedding (Homeomorph.neg ℝ)
⊢ IntegrableOn (fun x => f |x|) (Iic 0) (Measure.map Neg.neg volume)
state_after: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
m : MeasurableEmbedding fun x => -x := Homeomorph.measurableEmbedding (Homeomorph.neg ℝ)
⊢ IntegrableOn ((fun x => f |x|) ∘ fun x => -x) ((fun x => -x) ⁻¹' Iic 0) volume

tactic: simp_rw [Function.comp, abs_neg, neg_preimage, preimage_neg_Iic, neg_zero]
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
m : MeasurableEmbedding fun x => -x := Homeomorph.measurableEmbedding (Homeomorph.neg ℝ)
⊢ IntegrableOn ((fun x => f |x|) ∘ fun x => -x) ((fun x => -x) ⁻¹' Iic 0) volume
state_after: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
m : MeasurableEmbedding fun x => -x := Homeomorph.measurableEmbedding (Homeomorph.neg ℝ)
⊢ IntegrableOn (fun x => f |x|) (Ici 0) volume

tactic: exact integrableOn_Ici_iff_integrableOn_Ioi.mpr hf
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
m : MeasurableEmbedding fun x => -x := Homeomorph.measurableEmbedding (Homeomorph.neg ℝ)
⊢ IntegrableOn (fun x => f |x|) (Ici 0) volume
state_after: no goals

tactic: rw [← integral_union (Iic_disjoint_Ioi le_rfl) measurableSet_Ioi int_Iic hf,
  Iic_union_Ioi, restrict_univ]
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
⊢ ∫ (x : ℝ), f |x| = (∫ (x : ℝ) in Iic 0, f |x|) + ∫ (x : ℝ) in Ioi 0, f |x|
state_after: no goals

tactic: rw [two_mul, eq]
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
⊢ (∫ (x : ℝ) in Iic 0, f |x|) + ∫ (x : ℝ) in Ioi 0, f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x
state_after: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
⊢ (∫ (x : ℝ) in Iic 0, f |x|) + ∫ (x : ℝ) in Ioi 0, f x = (∫ (x : ℝ) in Ioi 0, f x) + ∫ (x : ℝ) in Ioi 0, f x

tactic: congr! 1
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
⊢ (∫ (x : ℝ) in Iic 0, f |x|) + ∫ (x : ℝ) in Ioi 0, f x = (∫ (x : ℝ) in Ioi 0, f x) + ∫ (x : ℝ) in Ioi 0, f x
state_after: case h.e'_5
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
⊢ ∫ (x : ℝ) in Iic 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x

tactic: rw [← neg_zero, ← integral_comp_neg_Iic, neg_zero]
state_before: case h.e'_5
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
⊢ ∫ (x : ℝ) in Iic 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
state_after: case h.e'_5
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
⊢ ∫ (x : ℝ) in Iic 0, f |x| = ∫ (x : ℝ) in Iic 0, f (-x)

tactic: refine setIntegral_congr measurableSet_Iic (fun _ hx => ?_)
state_before: case h.e'_5
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
⊢ ∫ (x : ℝ) in Iic 0, f |x| = ∫ (x : ℝ) in Iic 0, f (-x)
state_after: case h.e'_5
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
x✝ : ℝ
hx : x✝ ∈ Iic 0
⊢ f |x✝| = f (-x✝)

tactic: rw [abs_eq_neg_self.mpr (by exact hx)]
state_before: case h.e'_5
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
x✝ : ℝ
hx : x✝ ∈ Iic 0
⊢ f |x✝| = f (-x✝)
state_after: no goals

tactic: exact hx
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : IntegrableOn (fun x => f |x|) (Ioi 0) volume
int_Iic : IntegrableOn (fun x => f |x|) (Iic 0) volume
x✝ : ℝ
hx : x✝ ∈ Iic 0
⊢ x✝ ≤ 0
state_after: no goals

tactic: have : ¬ Integrable (fun x => f |x|) := by
  contrapose! hf
  exact hf.integrableOn
state_before: case neg
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : ¬IntegrableOn (fun x => f |x|) (Ioi 0) volume
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x
state_after: case neg
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : ¬IntegrableOn (fun x => f |x|) (Ioi 0) volume
this : ¬Integrable (fun x => f |x|) volume
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x

tactic: rw [← eq, integral_undef hf, integral_undef this, mul_zero]
state_before: case neg
f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : ¬IntegrableOn (fun x => f |x|) (Ioi 0) volume
this : ¬Integrable (fun x => f |x|) volume
⊢ ∫ (x : ℝ), f |x| = 2 * ∫ (x : ℝ) in Ioi 0, f x
state_after: no goals

tactic: contrapose! hf
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : ¬IntegrableOn (fun x => f |x|) (Ioi 0) volume
⊢ ¬Integrable (fun x => f |x|) volume
state_after: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : Integrable (fun x => f |x|) volume
⊢ IntegrableOn (fun x => f |x|) (Ioi 0) volume

tactic: exact hf.integrableOn
state_before: f : ℝ → ℝ
eq : ∫ (x : ℝ) in Ioi 0, f |x| = ∫ (x : ℝ) in Ioi 0, f x
hf : Integrable (fun x => f |x|) volume
⊢ IntegrableOn (fun x => f |x|) (Ioi 0) volume
state_after: no goals