l3lab/ntp-mathlib huggingface dataset:
@[simp]
lemma tilted_const' (μ : Measure α) (c : ℝ) :
    μ.tilted (fun _ ↦ c) = (μ Set.univ)⁻¹ • μ := by
  cases eq_zero_or_neZero μ with
  | inl h => rw [h]; simp
  | inr h0 =>
    simp only [Measure.tilted, withDensity_const, integral_const, smul_eq_mul]
    by_cases h_univ : μ Set.univ = ∞
    · 

Proof state:
case pos
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f : α → ℝ
μ : Measure α
c : ℝ
h0 : NeZero μ
h_univ : ↑↑μ Set.univ = ⊤
⊢ ENNReal.ofReal (rexp c / (ENNReal.toReal (↑↑μ Set.univ) * rexp c)) • μ = (↑↑μ Set.univ)⁻¹ • μ

Next tactic:
simp only [h_univ, ENNReal.top_toReal, zero_mul, log_zero, div_zero, ENNReal.ofReal_zero,
        zero_smul, ENNReal.inv_top]
@[simp]
lemma tilted_const' (μ : Measure α) (c : ℝ) :
    μ.tilted (fun _ ↦ c) = (μ Set.univ)⁻¹ • μ := by
  cases eq_zero_or_neZero μ with
  | inl h => rw [h]; simp
  | inr h0 =>
    simp only [Measure.tilted, withDensity_const, integral_const, smul_eq_mul]
    by_cases h_univ : μ Set.univ = ∞
    · simp only [h_univ, ENNReal.top_toReal, zero_mul, log_zero, div_zero, ENNReal.ofReal_zero,
        zero_smul, ENNReal.inv_top]
    

Proof state:
case neg
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f : α → ℝ
μ : Measure α
c : ℝ
h0 : NeZero μ
h_univ : ¬↑↑μ Set.univ = ⊤
⊢ ENNReal.ofReal (rexp c / (ENNReal.toReal (↑↑μ Set.univ) * rexp c)) • μ = (↑↑μ Set.univ)⁻¹ • μ

Next tactic:
congr
@[simp]
lemma tilted_const' (μ : Measure α) (c : ℝ) :
    μ.tilted (fun _ ↦ c) = (μ Set.univ)⁻¹ • μ := by
  cases eq_zero_or_neZero μ with
  | inl h => rw [h]; simp
  | inr h0 =>
    simp only [Measure.tilted, withDensity_const, integral_const, smul_eq_mul]
    by_cases h_univ : μ Set.univ = ∞
    · simp only [h_univ, ENNReal.top_toReal, zero_mul, log_zero, div_zero, ENNReal.ofReal_zero,
        zero_smul, ENNReal.inv_top]
    congr
    

Proof state:
case neg.e_a
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f : α → ℝ
μ : Measure α
c : ℝ
h0 : NeZero μ
h_univ : ¬↑↑μ Set.univ = ⊤
⊢ ENNReal.ofReal (rexp c / (ENNReal.toReal (↑↑μ Set.univ) * rexp c)) = (↑↑μ Set.univ)⁻¹

Next tactic:
rw [div_eq_mul_inv, mul_inv, mul_comm, mul_assoc, inv_mul_cancel (exp_pos _).ne', mul_one,
      ← ENNReal.toReal_inv, ENNReal.ofReal_toReal]
@[simp]
lemma tilted_const' (μ : Measure α) (c : ℝ) :
    μ.tilted (fun _ ↦ c) = (μ Set.univ)⁻¹ • μ := by
  cases eq_zero_or_neZero μ with
  | inl h => rw [h]; simp
  | inr h0 =>
    simp only [Measure.tilted, withDensity_const, integral_const, smul_eq_mul]
    by_cases h_univ : μ Set.univ = ∞
    · simp only [h_univ, ENNReal.top_toReal, zero_mul, log_zero, div_zero, ENNReal.ofReal_zero,
        zero_smul, ENNReal.inv_top]
    congr
    rw [div_eq_mul_inv, mul_inv, mul_comm, mul_assoc, inv_mul_cancel (exp_pos _).ne', mul_one,
      ← ENNReal.toReal_inv, ENNReal.ofReal_toReal]
    

Proof state:
case neg.e_a
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f : α → ℝ
μ : Measure α
c : ℝ
h0 : NeZero μ
h_univ : ¬↑↑μ Set.univ = ⊤
⊢ (↑↑μ Set.univ)⁻¹ ≠ ⊤

Next tactic:
simp [h0.out]
lemma tilted_const (μ : Measure α) [IsProbabilityMeasure μ] (c : ℝ) :
    μ.tilted (fun _ ↦ c) = μ := by 

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f : α → ℝ
μ : Measure α
inst✝ : IsProbabilityMeasure μ
c : ℝ
⊢ (μ.tilted fun x => c) = μ

Next tactic:
simp
@[simp]
lemma tilted_zero' (μ : Measure α) : μ.tilted 0 = (μ Set.univ)⁻¹ • μ := by
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f : α → ℝ
μ : Measure α
⊢ μ.tilted 0 = (↑↑μ Set.univ)⁻¹ • μ

Next tactic:
change μ.tilted (fun _ ↦ 0) = (μ Set.univ)⁻¹ • μ
@[simp]
lemma tilted_zero' (μ : Measure α) : μ.tilted 0 = (μ Set.univ)⁻¹ • μ := by
  change μ.tilted (fun _ ↦ 0) = (μ Set.univ)⁻¹ • μ
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f : α → ℝ
μ : Measure α
⊢ (μ.tilted fun x => 0) = (↑↑μ Set.univ)⁻¹ • μ

Next tactic:
simp
lemma tilted_zero (μ : Measure α) [IsProbabilityMeasure μ] : μ.tilted 0 = μ := by 

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f : α → ℝ
μ : Measure α
inst✝ : IsProbabilityMeasure μ
⊢ μ.tilted 0 = μ

Next tactic:
simp
lemma tilted_congr {g : α → ℝ} (hfg : f =ᵐ[μ] g) :
    μ.tilted f = μ.tilted g := by
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f g : α → ℝ
hfg : f =ᵐ[μ] g
⊢ μ.tilted f = μ.tilted g

Next tactic:
have h_int_eq : ∫ x, exp (f x) ∂μ = ∫ x, exp (g x) ∂μ := by
    refine integral_congr_ae ?_
    filter_upwards [hfg] with x hx
    rw [hx]
lemma tilted_congr {g : α → ℝ} (hfg : f =ᵐ[μ] g) :
    μ.tilted f = μ.tilted g := by
  have h_int_eq : ∫ x, exp (f x) ∂μ = ∫ x, exp (g x) ∂μ := by
    

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f g : α → ℝ
hfg : f =ᵐ[μ] g
⊢ ∫ (x : α), rexp (f x) ∂μ = ∫ (x : α), rexp (g x) ∂μ

Next tactic:
refine integral_congr_ae ?_
lemma tilted_congr {g : α → ℝ} (hfg : f =ᵐ[μ] g) :
    μ.tilted f = μ.tilted g := by
  have h_int_eq : ∫ x, exp (f x) ∂μ = ∫ x, exp (g x) ∂μ := by
    refine integral_congr_ae ?_
    

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f g : α → ℝ
hfg : f =ᵐ[μ] g
⊢ (fun x => rexp (f x)) =ᵐ[μ] fun x => rexp (g x)

Next tactic:
filter_upwards [hfg] with x hx
lemma tilted_congr {g : α → ℝ} (hfg : f =ᵐ[μ] g) :
    μ.tilted f = μ.tilted g := by
  have h_int_eq : ∫ x, exp (f x) ∂μ = ∫ x, exp (g x) ∂μ := by
    refine integral_congr_ae ?_
    filter_upwards [hfg] with x hx
    

Proof state:
case h
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f g : α → ℝ
hfg : f =ᵐ[μ] g
x : α
hx : f x = g x
⊢ rexp (f x) = rexp (g x)

Next tactic:
rw [hx]
lemma tilted_congr {g : α → ℝ} (hfg : f =ᵐ[μ] g) :
    μ.tilted f = μ.tilted g := by
  have h_int_eq : ∫ x, exp (f x) ∂μ = ∫ x, exp (g x) ∂μ := by
    refine integral_congr_ae ?_
    filter_upwards [hfg] with x hx
    rw [hx]
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f g : α → ℝ
hfg : f =ᵐ[μ] g
h_int_eq : ∫ (x : α), rexp (f x) ∂μ = ∫ (x : α), rexp (g x) ∂μ
⊢ μ.tilted f = μ.tilted g

Next tactic:
refine withDensity_congr_ae ?_
lemma tilted_congr {g : α → ℝ} (hfg : f =ᵐ[μ] g) :
    μ.tilted f = μ.tilted g := by
  have h_int_eq : ∫ x, exp (f x) ∂μ = ∫ x, exp (g x) ∂μ := by
    refine integral_congr_ae ?_
    filter_upwards [hfg] with x hx
    rw [hx]
  refine withDensity_congr_ae ?_
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f g : α → ℝ
hfg : f =ᵐ[μ] g
h_int_eq : ∫ (x : α), rexp (f x) ∂μ = ∫ (x : α), rexp (g x) ∂μ
⊢ (fun x => ENNReal.ofReal (rexp (f x) / ∫ (x : α), rexp (f x) ∂μ)) =ᵐ[μ] fun x =>
    ENNReal.ofReal (rexp (g x) / ∫ (x : α), rexp (g x) ∂μ)

Next tactic:
filter_upwards [hfg] with x hx
lemma tilted_congr {g : α → ℝ} (hfg : f =ᵐ[μ] g) :
    μ.tilted f = μ.tilted g := by
  have h_int_eq : ∫ x, exp (f x) ∂μ = ∫ x, exp (g x) ∂μ := by
    refine integral_congr_ae ?_
    filter_upwards [hfg] with x hx
    rw [hx]
  refine withDensity_congr_ae ?_
  filter_upwards [hfg] with x hx
  

Proof state:
case h
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f g : α → ℝ
hfg : f =ᵐ[μ] g
h_int_eq : ∫ (x : α), rexp (f x) ∂μ = ∫ (x : α), rexp (g x) ∂μ
x : α
hx : f x = g x
⊢ ENNReal.ofReal (rexp (f x) / ∫ (x : α), rexp (f x) ∂μ) = ENNReal.ofReal (rexp (g x) / ∫ (x : α), rexp (g x) ∂μ)

Next tactic:
rw [h_int_eq, hx]
lemma tilted_eq_withDensity_nnreal (μ : Measure α) (f : α → ℝ) :
    μ.tilted f = μ.withDensity (fun x ↦ ((↑) : ℝ≥0 → ℝ≥0∞)
      (⟨exp (f x) / ∫ x, exp (f x) ∂μ,
      div_nonneg (exp_pos _).le (integral_nonneg (fun _ ↦ (exp_pos _).le))⟩ : ℝ≥0)) := by
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f✝ : α → ℝ
μ : Measure α
f : α → ℝ
⊢ μ.tilted f =
    Measure.withDensity μ fun x =>
      ↑{ val := rexp (f x) / ∫ (x : α), rexp (f x) ∂μ, property := (_ : 0 ≤ rexp (f x) / ∫ (x : α), rexp (f x) ∂μ) }

Next tactic:
rw [Measure.tilted]
lemma tilted_eq_withDensity_nnreal (μ : Measure α) (f : α → ℝ) :
    μ.tilted f = μ.withDensity (fun x ↦ ((↑) : ℝ≥0 → ℝ≥0∞)
      (⟨exp (f x) / ∫ x, exp (f x) ∂μ,
      div_nonneg (exp_pos _).le (integral_nonneg (fun _ ↦ (exp_pos _).le))⟩ : ℝ≥0)) := by
  rw [Measure.tilted]
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f✝ : α → ℝ
μ : Measure α
f : α → ℝ
⊢ (Measure.withDensity μ fun x => ENNReal.ofReal (rexp (f x) / ∫ (x : α), rexp (f x) ∂μ)) =
    Measure.withDensity μ fun x =>
      ↑{ val := rexp (f x) / ∫ (x : α), rexp (f x) ∂μ, property := (_ : 0 ≤ rexp (f x) / ∫ (x : α), rexp (f x) ∂μ) }

Next tactic:
congr with x
lemma tilted_eq_withDensity_nnreal (μ : Measure α) (f : α → ℝ) :
    μ.tilted f = μ.withDensity (fun x ↦ ((↑) : ℝ≥0 → ℝ≥0∞)
      (⟨exp (f x) / ∫ x, exp (f x) ∂μ,
      div_nonneg (exp_pos _).le (integral_nonneg (fun _ ↦ (exp_pos _).le))⟩ : ℝ≥0)) := by
  rw [Measure.tilted]
  congr with x
  

Proof state:
case e_f.h
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f✝ : α → ℝ
μ : Measure α
f : α → ℝ
x : α
⊢ ENNReal.ofReal (rexp (f x) / ∫ (x : α), rexp (f x) ∂μ) =
    ↑{ val := rexp (f x) / ∫ (x : α), rexp (f x) ∂μ, property := (_ : 0 ≤ rexp (f x) / ∫ (x : α), rexp (f x) ∂μ) }

Next tactic:
rw [ENNReal.ofReal_eq_coe_nnreal]
lemma tilted_apply' (μ : Measure α) (f : α → ℝ) {s : Set α} (hs : MeasurableSet s) :
    μ.tilted f s = ∫⁻ a in s, ENNReal.ofReal (exp (f a) / ∫ x, exp (f x) ∂μ) ∂μ := by
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f✝ : α → ℝ
μ : Measure α
f : α → ℝ
s : Set α
hs : MeasurableSet s
⊢ ↑↑(μ.tilted f) s = ∫⁻ (a : α) in s, ENNReal.ofReal (rexp (f a) / ∫ (x : α), rexp (f x) ∂μ) ∂μ

Next tactic:
rw [Measure.tilted, withDensity_apply _ hs]
lemma tilted_apply (μ : Measure α) [SFinite μ] (f : α → ℝ) (s : Set α) :
    μ.tilted f s = ∫⁻ a in s, ENNReal.ofReal (exp (f a) / ∫ x, exp (f x) ∂μ) ∂μ := by
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
f✝ : α → ℝ
μ : Measure α
inst✝ : SFinite μ
f : α → ℝ
s : Set α
⊢ ↑↑(μ.tilted f) s = ∫⁻ (a : α) in s, ENNReal.ofReal (rexp (f a) / ∫ (x : α), rexp (f x) ∂μ) ∂μ

Next tactic:
rw [Measure.tilted, withDensity_apply' _ s]
lemma tilted_apply_eq_ofReal_integral' {s : Set α} (f : α → ℝ) (hs : MeasurableSet s) :
    μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s : Set α
f : α → ℝ
hs : MeasurableSet s
⊢ ↑↑(μ.tilted f) s = ENNReal.ofReal (∫ (a : α) in s, rexp (f a) / ∫ (x : α), rexp (f x) ∂μ ∂μ)

Next tactic:
by_cases hf : Integrable (fun x ↦ exp (f x)) μ
lemma tilted_apply_eq_ofReal_integral' {s : Set α} (f : α → ℝ) (hs : MeasurableSet s) :
    μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · 

Proof state:
case pos
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s : Set α
f : α → ℝ
hs : MeasurableSet s
hf : Integrable fun x => rexp (f x)
⊢ ↑↑(μ.tilted f) s = ENNReal.ofReal (∫ (a : α) in s, rexp (f a) / ∫ (x : α), rexp (f x) ∂μ ∂μ)

Next tactic:
rw [tilted_apply' _ _ hs, ← ofReal_integral_eq_lintegral_ofReal]
lemma tilted_apply_eq_ofReal_integral' {s : Set α} (f : α → ℝ) (hs : MeasurableSet s) :
    μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · rw [tilted_apply' _ _ hs, ← ofReal_integral_eq_lintegral_ofReal]
    · 

Proof state:
case pos.hfi
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s : Set α
f : α → ℝ
hs : MeasurableSet s
hf : Integrable fun x => rexp (f x)
⊢ Integrable fun a => rexp (f a) / ∫ (x : α), rexp (f x) ∂μ

Next tactic:
exact hf.integrableOn.div_const _
lemma tilted_apply_eq_ofReal_integral' {s : Set α} (f : α → ℝ) (hs : MeasurableSet s) :
    μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · rw [tilted_apply' _ _ hs, ← ofReal_integral_eq_lintegral_ofReal]
    · exact hf.integrableOn.div_const _
    · 

Proof state:
case pos.f_nn
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s : Set α
f : α → ℝ
hs : MeasurableSet s
hf : Integrable fun x => rexp (f x)
⊢ 0 ≤ᵐ[Measure.restrict μ s] fun a => rexp (f a) / ∫ (x : α), rexp (f x) ∂μ

Next tactic:
exact ae_of_all _
        (fun _ ↦ div_nonneg (exp_pos _).le (integral_nonneg (fun _ ↦ (exp_pos _).le)))
lemma tilted_apply_eq_ofReal_integral' {s : Set α} (f : α → ℝ) (hs : MeasurableSet s) :
    μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · rw [tilted_apply' _ _ hs, ← ofReal_integral_eq_lintegral_ofReal]
    · exact hf.integrableOn.div_const _
    · exact ae_of_all _
        (fun _ ↦ div_nonneg (exp_pos _).le (integral_nonneg (fun _ ↦ (exp_pos _).le)))
  · 

Proof state:
case neg
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
s : Set α
f : α → ℝ
hs : MeasurableSet s
hf : ¬Integrable fun x => rexp (f x)
⊢ ↑↑(μ.tilted f) s = ENNReal.ofReal (∫ (a : α) in s, rexp (f a) / ∫ (x : α), rexp (f x) ∂μ ∂μ)

Next tactic:
simp only [hf, not_false_eq_true, tilted_of_not_integrable, Measure.zero_toOuterMeasure,
      OuterMeasure.coe_zero, Pi.zero_apply, integral_undef hf, div_zero, integral_zero,
      ENNReal.ofReal_zero]
lemma tilted_apply_eq_ofReal_integral [SFinite μ] (f : α → ℝ) (s : Set α) :
    μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
inst✝ : SFinite μ
f : α → ℝ
s : Set α
⊢ ↑↑(μ.tilted f) s = ENNReal.ofReal (∫ (a : α) in s, rexp (f a) / ∫ (x : α), rexp (f x) ∂μ ∂μ)

Next tactic:
by_cases hf : Integrable (fun x ↦ exp (f x)) μ
lemma tilted_apply_eq_ofReal_integral [SFinite μ] (f : α → ℝ) (s : Set α) :
    μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · 

Proof state:
case pos
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
inst✝ : SFinite μ
f : α → ℝ
s : Set α
hf : Integrable fun x => rexp (f x)
⊢ ↑↑(μ.tilted f) s = ENNReal.ofReal (∫ (a : α) in s, rexp (f a) / ∫ (x : α), rexp (f x) ∂μ ∂μ)

Next tactic:
rw [tilted_apply _ _, ← ofReal_integral_eq_lintegral_ofReal]
lemma tilted_apply_eq_ofReal_integral [SFinite μ] (f : α → ℝ) (s : Set α) :
    μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · rw [tilted_apply _ _, ← ofReal_integral_eq_lintegral_ofReal]
    · 

Proof state:
case pos.hfi
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
inst✝ : SFinite μ
f : α → ℝ
s : Set α
hf : Integrable fun x => rexp (f x)
⊢ Integrable fun a => rexp (f a) / ∫ (x : α), rexp (f x) ∂μ

Next tactic:
exact hf.integrableOn.div_const _
lemma tilted_apply_eq_ofReal_integral [SFinite μ] (f : α → ℝ) (s : Set α) :
    μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · rw [tilted_apply _ _, ← ofReal_integral_eq_lintegral_ofReal]
    · exact hf.integrableOn.div_const _
    · 

Proof state:
case pos.f_nn
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
inst✝ : SFinite μ
f : α → ℝ
s : Set α
hf : Integrable fun x => rexp (f x)
⊢ 0 ≤ᵐ[Measure.restrict μ s] fun a => rexp (f a) / ∫ (x : α), rexp (f x) ∂μ

Next tactic:
exact ae_of_all _
        (fun _ ↦ div_nonneg (exp_pos _).le (integral_nonneg (fun _ ↦ (exp_pos _).le)))
lemma tilted_apply_eq_ofReal_integral [SFinite μ] (f : α → ℝ) (s : Set α) :
    μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · rw [tilted_apply _ _, ← ofReal_integral_eq_lintegral_ofReal]
    · exact hf.integrableOn.div_const _
    · exact ae_of_all _
        (fun _ ↦ div_nonneg (exp_pos _).le (integral_nonneg (fun _ ↦ (exp_pos _).le)))
  · 

Proof state:
case neg
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ : α → ℝ
inst✝ : SFinite μ
f : α → ℝ
s : Set α
hf : ¬Integrable fun x => rexp (f x)
⊢ ↑↑(μ.tilted f) s = ENNReal.ofReal (∫ (a : α) in s, rexp (f a) / ∫ (x : α), rexp (f x) ∂μ ∂μ)

Next tactic:
simp only [hf, not_false_eq_true, tilted_of_not_integrable, Measure.zero_toOuterMeasure,
      OuterMeasure.coe_zero, Pi.zero_apply, integral_undef hf, div_zero, integral_zero,
      ENNReal.ofReal_zero]
instance isFiniteMeasure_tilted : IsFiniteMeasure (μ.tilted f) := by
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
⊢ IsFiniteMeasure (μ.tilted f)

Next tactic:
by_cases hf : Integrable (fun x ↦ exp (f x)) μ
instance isFiniteMeasure_tilted : IsFiniteMeasure (μ.tilted f) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · 

Proof state:
case pos
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : Integrable fun x => rexp (f x)
⊢ IsFiniteMeasure (μ.tilted f)

Next tactic:
refine isFiniteMeasure_withDensity_ofReal ?_
instance isFiniteMeasure_tilted : IsFiniteMeasure (μ.tilted f) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · refine isFiniteMeasure_withDensity_ofReal ?_
    

Proof state:
case pos
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : Integrable fun x => rexp (f x)
⊢ HasFiniteIntegral fun x => rexp (f x) / ∫ (x : α), rexp (f x) ∂μ

Next tactic:
suffices Integrable (fun x ↦ exp (f x) / ∫ x, exp (f x) ∂μ) μ by exact this.2
instance isFiniteMeasure_tilted : IsFiniteMeasure (μ.tilted f) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · refine isFiniteMeasure_withDensity_ofReal ?_
    suffices Integrable (fun x ↦ exp (f x) / ∫ x, exp (f x) ∂μ) μ by 

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : Integrable fun x => rexp (f x)
this : Integrable fun x => rexp (f x) / ∫ (x : α), rexp (f x) ∂μ
⊢ HasFiniteIntegral fun x => rexp (f x) / ∫ (x : α), rexp (f x) ∂μ

Next tactic:
exact this.2
instance isFiniteMeasure_tilted : IsFiniteMeasure (μ.tilted f) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · refine isFiniteMeasure_withDensity_ofReal ?_
    suffices Integrable (fun x ↦ exp (f x) / ∫ x, exp (f x) ∂μ) μ by exact this.2
    

Proof state:
case pos
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : Integrable fun x => rexp (f x)
⊢ Integrable fun x => rexp (f x) / ∫ (x : α), rexp (f x) ∂μ

Next tactic:
exact hf.div_const _
instance isFiniteMeasure_tilted : IsFiniteMeasure (μ.tilted f) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · refine isFiniteMeasure_withDensity_ofReal ?_
    suffices Integrable (fun x ↦ exp (f x) / ∫ x, exp (f x) ∂μ) μ by exact this.2
    exact hf.div_const _
  · 

Proof state:
case neg
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : ¬Integrable fun x => rexp (f x)
⊢ IsFiniteMeasure (μ.tilted f)

Next tactic:
simp only [hf, not_false_eq_true, tilted_of_not_integrable]
instance isFiniteMeasure_tilted : IsFiniteMeasure (μ.tilted f) := by
  by_cases hf : Integrable (fun x ↦ exp (f x)) μ
  · refine isFiniteMeasure_withDensity_ofReal ?_
    suffices Integrable (fun x ↦ exp (f x) / ∫ x, exp (f x) ∂μ) μ by exact this.2
    exact hf.div_const _
  · simp only [hf, not_false_eq_true, tilted_of_not_integrable]
    

Proof state:
case neg
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : ¬Integrable fun x => rexp (f x)
⊢ IsFiniteMeasure 0

Next tactic:
infer_instance
lemma isProbabilityMeasure_tilted [NeZero μ] (hf : Integrable (fun x ↦ exp (f x)) μ) :
    IsProbabilityMeasure (μ.tilted f) := by
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
inst✝ : NeZero μ
hf : Integrable fun x => rexp (f x)
⊢ IsProbabilityMeasure (μ.tilted f)

Next tactic:
constructor
lemma isProbabilityMeasure_tilted [NeZero μ] (hf : Integrable (fun x ↦ exp (f x)) μ) :
    IsProbabilityMeasure (μ.tilted f) := by
  constructor
  

Proof state:
case measure_univ
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
inst✝ : NeZero μ
hf : Integrable fun x => rexp (f x)
⊢ ↑↑(μ.tilted f) Set.univ = 1

Next tactic:
simp_rw [tilted_apply' _ _ MeasurableSet.univ, set_lintegral_univ,
    ENNReal.ofReal_div_of_pos (integral_exp_pos hf), div_eq_mul_inv]
lemma isProbabilityMeasure_tilted [NeZero μ] (hf : Integrable (fun x ↦ exp (f x)) μ) :
    IsProbabilityMeasure (μ.tilted f) := by
  constructor
  simp_rw [tilted_apply' _ _ MeasurableSet.univ, set_lintegral_univ,
    ENNReal.ofReal_div_of_pos (integral_exp_pos hf), div_eq_mul_inv]
  

Proof state:
case measure_univ
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
inst✝ : NeZero μ
hf : Integrable fun x => rexp (f x)
⊢ ∫⁻ (a : α), ENNReal.ofReal (rexp (f a)) * (ENNReal.ofReal (∫ (x : α), rexp (f x) ∂μ))⁻¹ ∂μ = 1

Next tactic:
rw [lintegral_mul_const'' _ hf.1.aemeasurable.ennreal_ofReal,
    ← ofReal_integral_eq_lintegral_ofReal hf (ae_of_all _ fun _ ↦ (exp_pos _).le),
    ENNReal.mul_inv_cancel]
lemma isProbabilityMeasure_tilted [NeZero μ] (hf : Integrable (fun x ↦ exp (f x)) μ) :
    IsProbabilityMeasure (μ.tilted f) := by
  constructor
  simp_rw [tilted_apply' _ _ MeasurableSet.univ, set_lintegral_univ,
    ENNReal.ofReal_div_of_pos (integral_exp_pos hf), div_eq_mul_inv]
  rw [lintegral_mul_const'' _ hf.1.aemeasurable.ennreal_ofReal,
    ← ofReal_integral_eq_lintegral_ofReal hf (ae_of_all _ fun _ ↦ (exp_pos _).le),
    ENNReal.mul_inv_cancel]
  

Proof state:
case measure_univ.h0
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
inst✝ : NeZero μ
hf : Integrable fun x => rexp (f x)
⊢ ENNReal.ofReal (∫ (x : α), rexp (f x) ∂μ) ≠ 0
case measure_univ.ht
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
inst✝ : NeZero μ
hf : Integrable fun x => rexp (f x)
⊢ ENNReal.ofReal (∫ (x : α), rexp (f x) ∂μ) ≠ ⊤

Next tactic:
simp only [ne_eq, ENNReal.ofReal_eq_zero, not_le]
lemma isProbabilityMeasure_tilted [NeZero μ] (hf : Integrable (fun x ↦ exp (f x)) μ) :
    IsProbabilityMeasure (μ.tilted f) := by
  constructor
  simp_rw [tilted_apply' _ _ MeasurableSet.univ, set_lintegral_univ,
    ENNReal.ofReal_div_of_pos (integral_exp_pos hf), div_eq_mul_inv]
  rw [lintegral_mul_const'' _ hf.1.aemeasurable.ennreal_ofReal,
    ← ofReal_integral_eq_lintegral_ofReal hf (ae_of_all _ fun _ ↦ (exp_pos _).le),
    ENNReal.mul_inv_cancel]
  simp only [ne_eq, ENNReal.ofReal_eq_zero, not_le]
  · 

Proof state:
case measure_univ.h0
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
inst✝ : NeZero μ
hf : Integrable fun x => rexp (f x)
⊢ 0 < ∫ (x : α), rexp (f x) ∂μ

Next tactic:
exact integral_exp_pos hf
lemma isProbabilityMeasure_tilted [NeZero μ] (hf : Integrable (fun x ↦ exp (f x)) μ) :
    IsProbabilityMeasure (μ.tilted f) := by
  constructor
  simp_rw [tilted_apply' _ _ MeasurableSet.univ, set_lintegral_univ,
    ENNReal.ofReal_div_of_pos (integral_exp_pos hf), div_eq_mul_inv]
  rw [lintegral_mul_const'' _ hf.1.aemeasurable.ennreal_ofReal,
    ← ofReal_integral_eq_lintegral_ofReal hf (ae_of_all _ fun _ ↦ (exp_pos _).le),
    ENNReal.mul_inv_cancel]
  simp only [ne_eq, ENNReal.ofReal_eq_zero, not_le]
  · exact integral_exp_pos hf
  · 

Proof state:
case measure_univ.ht
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f : α → ℝ
inst✝ : NeZero μ
hf : Integrable fun x => rexp (f x)
⊢ ENNReal.ofReal (∫ (x : α), rexp (f x) ∂μ) ≠ ⊤

Next tactic:
simp
lemma set_lintegral_tilted' (f : α → ℝ) (g : α → ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) :
    ∫⁻ x in s, g x ∂(μ.tilted f)
      = ∫⁻ x in s, ENNReal.ofReal (exp (f x) / ∫ x, exp (f x) ∂μ) * g x ∂μ := by
  

Proof state:
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ f : α → ℝ
g : α → ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (x : α) in s, g x ∂μ.tilted f = ∫⁻ (x : α) in s, ENNReal.ofReal (rexp (f x) / ∫ (x : α), rexp (f x) ∂μ) * g x ∂μ

Next tactic:
by_cases hf : AEMeasurable f μ
lemma set_lintegral_tilted' (f : α → ℝ) (g : α → ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) :
    ∫⁻ x in s, g x ∂(μ.tilted f)
      = ∫⁻ x in s, ENNReal.ofReal (exp (f x) / ∫ x, exp (f x) ∂μ) * g x ∂μ := by
  by_cases hf : AEMeasurable f μ
  · 

Proof state:
case pos
α : Type u_1
mα : MeasurableSpace α
μ : Measure α
f✝ f : α → ℝ
g : α → ℝ≥0∞
s : Set α
hs : MeasurableSet s
hf : AEMeasurable f
⊢ ∫⁻ (x : α) in s, g x ∂μ.tilted f = ∫⁻ (x : α) in s, ENNReal.ofReal (rexp (f x) / ∫ (x : α), rexp (f x) ∂μ) * g x ∂μ

Next tactic:
rw [Measure.tilted, set_lintegral_withDensity_eq_set_lintegral_mul_non_measurable₀]