l3lab/ntp-mathlib huggingface dataset:
theorem condexpL2_indicator_nonneg (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞)
    [SigmaFinite (μ.trim hm)] : (0 : α → ℝ) ≤ᵐ[μ]
    condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) := by
  have h : AEStronglyMeasurable' m (condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) μ :=
    aeStronglyMeasurable'_condexpL2 _ _
  refine' EventuallyLE.trans_eq _ h.ae_eq_mk.symm
  refine' @ae_le_of_ae_le_trim _ _ _ _ _ _ hm (0 : α → ℝ) _ _
  refine' ae_nonneg_of_forall_set_integral_nonneg_of_sigmaFinite _ _
  · rintro t - -
    refine @Integrable.integrableOn _ _ m _ _ _ _ ?_
    refine' Integrable.trim hm _ _
    · rw [integrable_congr h.ae_eq_mk.symm]
      exact integrable_condexpL2_indicator hm hs hμs _
    · exact h.stronglyMeasurable_mk
  · intro t ht hμt
    rw [← set_integral_trim hm h.stronglyMeasurable_mk ht]
    

Proof state:
case refine'_2
α : Type u_1
E : Type u_2
E' : Type u_3
F : Type u_4
G : Type u_5
G' : Type u_6
𝕜 : Type u_7
p : ℝ≥0∞
inst✝²⁰ : IsROrC 𝕜
inst✝¹⁹ : NormedAddCommGroup E
inst✝¹⁸ : InnerProductSpace 𝕜 E
inst✝¹⁷ : CompleteSpace E
inst✝¹⁶ : NormedAddCommGroup E'
inst✝¹⁵ : InnerProductSpace 𝕜 E'
inst✝¹⁴ : CompleteSpace E'
inst✝¹³ : NormedSpace ℝ E'
inst✝¹² : NormedAddCommGroup F
inst✝¹¹ : NormedSpace 𝕜 F
inst✝¹⁰ : NormedAddCommGroup G
inst✝⁹ : NormedAddCommGroup G'
inst✝⁸ : NormedSpace ℝ G'
inst✝⁷ : CompleteSpace G'
m m0 : MeasurableSpace α
μ : Measure α
s t✝ : Set α
E'' : Type u_8
𝕜' : Type u_9
inst✝⁶ : IsROrC 𝕜'
inst✝⁵ : NormedAddCommGroup E''
inst✝⁴ : InnerProductSpace 𝕜' E''
inst✝³ : CompleteSpace E''
inst✝² : NormedSpace ℝ E''
inst✝¹ : NormedSpace ℝ G
hm✝ hm : m ≤ m0
hs : MeasurableSet s
hμs : ↑↑μ s ≠ ⊤
inst✝ : SigmaFinite (Measure.trim μ hm)
h : AEStronglyMeasurable' m (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) μ
t : Set α
ht : MeasurableSet t
hμt : ↑↑(Measure.trim μ hm) t < ⊤
⊢ 0 ≤ ∫ (x : α) in t, AEStronglyMeasurable'.mk (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) h x ∂μ

Next tactic:
have h_ae :
      ∀ᵐ x ∂μ, x ∈ t → h.mk _ x = (condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) x := by
      filter_upwards [h.ae_eq_mk] with x hx
      exact fun _ => hx.symm
theorem condexpL2_indicator_nonneg (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞)
    [SigmaFinite (μ.trim hm)] : (0 : α → ℝ) ≤ᵐ[μ]
    condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) := by
  have h : AEStronglyMeasurable' m (condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) μ :=
    aeStronglyMeasurable'_condexpL2 _ _
  refine' EventuallyLE.trans_eq _ h.ae_eq_mk.symm
  refine' @ae_le_of_ae_le_trim _ _ _ _ _ _ hm (0 : α → ℝ) _ _
  refine' ae_nonneg_of_forall_set_integral_nonneg_of_sigmaFinite _ _
  · rintro t - -
    refine @Integrable.integrableOn _ _ m _ _ _ _ ?_
    refine' Integrable.trim hm _ _
    · rw [integrable_congr h.ae_eq_mk.symm]
      exact integrable_condexpL2_indicator hm hs hμs _
    · exact h.stronglyMeasurable_mk
  · intro t ht hμt
    rw [← set_integral_trim hm h.stronglyMeasurable_mk ht]
    have h_ae :
      ∀ᵐ x ∂μ, x ∈ t → h.mk _ x = (condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) x := by
      

Proof state:
α : Type u_1
E : Type u_2
E' : Type u_3
F : Type u_4
G : Type u_5
G' : Type u_6
𝕜 : Type u_7
p : ℝ≥0∞
inst✝²⁰ : IsROrC 𝕜
inst✝¹⁹ : NormedAddCommGroup E
inst✝¹⁸ : InnerProductSpace 𝕜 E
inst✝¹⁷ : CompleteSpace E
inst✝¹⁶ : NormedAddCommGroup E'
inst✝¹⁵ : InnerProductSpace 𝕜 E'
inst✝¹⁴ : CompleteSpace E'
inst✝¹³ : NormedSpace ℝ E'
inst✝¹² : NormedAddCommGroup F
inst✝¹¹ : NormedSpace 𝕜 F
inst✝¹⁰ : NormedAddCommGroup G
inst✝⁹ : NormedAddCommGroup G'
inst✝⁸ : NormedSpace ℝ G'
inst✝⁷ : CompleteSpace G'
m m0 : MeasurableSpace α
μ : Measure α
s t✝ : Set α
E'' : Type u_8
𝕜' : Type u_9
inst✝⁶ : IsROrC 𝕜'
inst✝⁵ : NormedAddCommGroup E''
inst✝⁴ : InnerProductSpace 𝕜' E''
inst✝³ : CompleteSpace E''
inst✝² : NormedSpace ℝ E''
inst✝¹ : NormedSpace ℝ G
hm✝ hm : m ≤ m0
hs : MeasurableSet s
hμs : ↑↑μ s ≠ ⊤
inst✝ : SigmaFinite (Measure.trim μ hm)
h : AEStronglyMeasurable' m (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) μ
t : Set α
ht : MeasurableSet t
hμt : ↑↑(Measure.trim μ hm) t < ⊤
⊢ ∀ᵐ (x : α) ∂μ,
    x ∈ t →
      AEStronglyMeasurable'.mk (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) h x =
        ↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1)) x

Next tactic:
filter_upwards [h.ae_eq_mk] with x hx
theorem condexpL2_indicator_nonneg (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞)
    [SigmaFinite (μ.trim hm)] : (0 : α → ℝ) ≤ᵐ[μ]
    condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) := by
  have h : AEStronglyMeasurable' m (condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) μ :=
    aeStronglyMeasurable'_condexpL2 _ _
  refine' EventuallyLE.trans_eq _ h.ae_eq_mk.symm
  refine' @ae_le_of_ae_le_trim _ _ _ _ _ _ hm (0 : α → ℝ) _ _
  refine' ae_nonneg_of_forall_set_integral_nonneg_of_sigmaFinite _ _
  · rintro t - -
    refine @Integrable.integrableOn _ _ m _ _ _ _ ?_
    refine' Integrable.trim hm _ _
    · rw [integrable_congr h.ae_eq_mk.symm]
      exact integrable_condexpL2_indicator hm hs hμs _
    · exact h.stronglyMeasurable_mk
  · intro t ht hμt
    rw [← set_integral_trim hm h.stronglyMeasurable_mk ht]
    have h_ae :
      ∀ᵐ x ∂μ, x ∈ t → h.mk _ x = (condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) x := by
      filter_upwards [h.ae_eq_mk] with x hx
      

Proof state:
case h
α : Type u_1
E : Type u_2
E' : Type u_3
F : Type u_4
G : Type u_5
G' : Type u_6
𝕜 : Type u_7
p : ℝ≥0∞
inst✝²⁰ : IsROrC 𝕜
inst✝¹⁹ : NormedAddCommGroup E
inst✝¹⁸ : InnerProductSpace 𝕜 E
inst✝¹⁷ : CompleteSpace E
inst✝¹⁶ : NormedAddCommGroup E'
inst✝¹⁵ : InnerProductSpace 𝕜 E'
inst✝¹⁴ : CompleteSpace E'
inst✝¹³ : NormedSpace ℝ E'
inst✝¹² : NormedAddCommGroup F
inst✝¹¹ : NormedSpace 𝕜 F
inst✝¹⁰ : NormedAddCommGroup G
inst✝⁹ : NormedAddCommGroup G'
inst✝⁸ : NormedSpace ℝ G'
inst✝⁷ : CompleteSpace G'
m m0 : MeasurableSpace α
μ : Measure α
s t✝ : Set α
E'' : Type u_8
𝕜' : Type u_9
inst✝⁶ : IsROrC 𝕜'
inst✝⁵ : NormedAddCommGroup E''
inst✝⁴ : InnerProductSpace 𝕜' E''
inst✝³ : CompleteSpace E''
inst✝² : NormedSpace ℝ E''
inst✝¹ : NormedSpace ℝ G
hm✝ hm : m ≤ m0
hs : MeasurableSet s
hμs : ↑↑μ s ≠ ⊤
inst✝ : SigmaFinite (Measure.trim μ hm)
h : AEStronglyMeasurable' m (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) μ
t : Set α
ht : MeasurableSet t
hμt : ↑↑(Measure.trim μ hm) t < ⊤
x : α
hx :
  ↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1)) x =
    AEStronglyMeasurable'.mk (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) h x
⊢ x ∈ t →
    AEStronglyMeasurable'.mk (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) h x =
      ↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1)) x

Next tactic:
exact fun _ => hx.symm
theorem condexpL2_indicator_nonneg (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞)
    [SigmaFinite (μ.trim hm)] : (0 : α → ℝ) ≤ᵐ[μ]
    condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) := by
  have h : AEStronglyMeasurable' m (condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) μ :=
    aeStronglyMeasurable'_condexpL2 _ _
  refine' EventuallyLE.trans_eq _ h.ae_eq_mk.symm
  refine' @ae_le_of_ae_le_trim _ _ _ _ _ _ hm (0 : α → ℝ) _ _
  refine' ae_nonneg_of_forall_set_integral_nonneg_of_sigmaFinite _ _
  · rintro t - -
    refine @Integrable.integrableOn _ _ m _ _ _ _ ?_
    refine' Integrable.trim hm _ _
    · rw [integrable_congr h.ae_eq_mk.symm]
      exact integrable_condexpL2_indicator hm hs hμs _
    · exact h.stronglyMeasurable_mk
  · intro t ht hμt
    rw [← set_integral_trim hm h.stronglyMeasurable_mk ht]
    have h_ae :
      ∀ᵐ x ∂μ, x ∈ t → h.mk _ x = (condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) x := by
      filter_upwards [h.ae_eq_mk] with x hx
      exact fun _ => hx.symm
    

Proof state:
case refine'_2
α : Type u_1
E : Type u_2
E' : Type u_3
F : Type u_4
G : Type u_5
G' : Type u_6
𝕜 : Type u_7
p : ℝ≥0∞
inst✝²⁰ : IsROrC 𝕜
inst✝¹⁹ : NormedAddCommGroup E
inst✝¹⁸ : InnerProductSpace 𝕜 E
inst✝¹⁷ : CompleteSpace E
inst✝¹⁶ : NormedAddCommGroup E'
inst✝¹⁵ : InnerProductSpace 𝕜 E'
inst✝¹⁴ : CompleteSpace E'
inst✝¹³ : NormedSpace ℝ E'
inst✝¹² : NormedAddCommGroup F
inst✝¹¹ : NormedSpace 𝕜 F
inst✝¹⁰ : NormedAddCommGroup G
inst✝⁹ : NormedAddCommGroup G'
inst✝⁸ : NormedSpace ℝ G'
inst✝⁷ : CompleteSpace G'
m m0 : MeasurableSpace α
μ : Measure α
s t✝ : Set α
E'' : Type u_8
𝕜' : Type u_9
inst✝⁶ : IsROrC 𝕜'
inst✝⁵ : NormedAddCommGroup E''
inst✝⁴ : InnerProductSpace 𝕜' E''
inst✝³ : CompleteSpace E''
inst✝² : NormedSpace ℝ E''
inst✝¹ : NormedSpace ℝ G
hm✝ hm : m ≤ m0
hs : MeasurableSet s
hμs : ↑↑μ s ≠ ⊤
inst✝ : SigmaFinite (Measure.trim μ hm)
h : AEStronglyMeasurable' m (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) μ
t : Set α
ht : MeasurableSet t
hμt : ↑↑(Measure.trim μ hm) t < ⊤
h_ae :
  ∀ᵐ (x : α) ∂μ,
    x ∈ t →
      AEStronglyMeasurable'.mk (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) h x =
        ↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1)) x
⊢ 0 ≤ ∫ (x : α) in t, AEStronglyMeasurable'.mk (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) h x ∂μ

Next tactic:
rw [set_integral_congr_ae (hm t ht) h_ae,
      set_integral_condexpL2_indicator ht hs ((le_trim hm).trans_lt hμt).ne hμs]
theorem condexpL2_indicator_nonneg (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞)
    [SigmaFinite (μ.trim hm)] : (0 : α → ℝ) ≤ᵐ[μ]
    condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) := by
  have h : AEStronglyMeasurable' m (condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) μ :=
    aeStronglyMeasurable'_condexpL2 _ _
  refine' EventuallyLE.trans_eq _ h.ae_eq_mk.symm
  refine' @ae_le_of_ae_le_trim _ _ _ _ _ _ hm (0 : α → ℝ) _ _
  refine' ae_nonneg_of_forall_set_integral_nonneg_of_sigmaFinite _ _
  · rintro t - -
    refine @Integrable.integrableOn _ _ m _ _ _ _ ?_
    refine' Integrable.trim hm _ _
    · rw [integrable_congr h.ae_eq_mk.symm]
      exact integrable_condexpL2_indicator hm hs hμs _
    · exact h.stronglyMeasurable_mk
  · intro t ht hμt
    rw [← set_integral_trim hm h.stronglyMeasurable_mk ht]
    have h_ae :
      ∀ᵐ x ∂μ, x ∈ t → h.mk _ x = (condexpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) x := by
      filter_upwards [h.ae_eq_mk] with x hx
      exact fun _ => hx.symm
    rw [set_integral_congr_ae (hm t ht) h_ae,
      set_integral_condexpL2_indicator ht hs ((le_trim hm).trans_lt hμt).ne hμs]
    

Proof state:
case refine'_2
α : Type u_1
E : Type u_2
E' : Type u_3
F : Type u_4
G : Type u_5
G' : Type u_6
𝕜 : Type u_7
p : ℝ≥0∞
inst✝²⁰ : IsROrC 𝕜
inst✝¹⁹ : NormedAddCommGroup E
inst✝¹⁸ : InnerProductSpace 𝕜 E
inst✝¹⁷ : CompleteSpace E
inst✝¹⁶ : NormedAddCommGroup E'
inst✝¹⁵ : InnerProductSpace 𝕜 E'
inst✝¹⁴ : CompleteSpace E'
inst✝¹³ : NormedSpace ℝ E'
inst✝¹² : NormedAddCommGroup F
inst✝¹¹ : NormedSpace 𝕜 F
inst✝¹⁰ : NormedAddCommGroup G
inst✝⁹ : NormedAddCommGroup G'
inst✝⁸ : NormedSpace ℝ G'
inst✝⁷ : CompleteSpace G'
m m0 : MeasurableSpace α
μ : Measure α
s t✝ : Set α
E'' : Type u_8
𝕜' : Type u_9
inst✝⁶ : IsROrC 𝕜'
inst✝⁵ : NormedAddCommGroup E''
inst✝⁴ : InnerProductSpace 𝕜' E''
inst✝³ : CompleteSpace E''
inst✝² : NormedSpace ℝ E''
inst✝¹ : NormedSpace ℝ G
hm✝ hm : m ≤ m0
hs : MeasurableSet s
hμs : ↑↑μ s ≠ ⊤
inst✝ : SigmaFinite (Measure.trim μ hm)
h : AEStronglyMeasurable' m (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) μ
t : Set α
ht : MeasurableSet t
hμt : ↑↑(Measure.trim μ hm) t < ⊤
h_ae :
  ∀ᵐ (x : α) ∂μ,
    x ∈ t →
      AEStronglyMeasurable'.mk (↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1))) h x =
        ↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1)) x
⊢ 0 ≤ ENNReal.toReal (↑↑μ (s ∩ t))

Next tactic:
exact ENNReal.toReal_nonneg
theorem condexpIndSMul_nonneg {E} [NormedLatticeAddCommGroup E] [NormedSpace ℝ E] [OrderedSMul ℝ E]
    [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E) (hx : 0 ≤ x) :
    (0 : α → E) ≤ᵐ[μ] condexpIndSMul hm hs hμs x := by
  

Proof state:
α : Type u_1
E✝ : Type u_2
E' : Type u_3
F : Type u_4
G : Type u_5
G' : Type u_6
𝕜 : Type u_7
p : ℝ≥0∞
inst✝²³ : IsROrC 𝕜
inst✝²² : NormedAddCommGroup E✝
inst✝²¹ : InnerProductSpace 𝕜 E✝
inst✝²⁰ : CompleteSpace E✝
inst✝¹⁹ : NormedAddCommGroup E'
inst✝¹⁸ : InnerProductSpace 𝕜 E'
inst✝¹⁷ : CompleteSpace E'
inst✝¹⁶ : NormedSpace ℝ E'
inst✝¹⁵ : NormedAddCommGroup F
inst✝¹⁴ : NormedSpace 𝕜 F
inst✝¹³ : NormedAddCommGroup G
inst✝¹² : NormedAddCommGroup G'
inst✝¹¹ : NormedSpace ℝ G'
inst✝¹⁰ : CompleteSpace G'
m m0 : MeasurableSpace α
μ : Measure α
s t : Set α
E'' : Type u_8
𝕜' : Type u_9
inst✝⁹ : IsROrC 𝕜'
inst✝⁸ : NormedAddCommGroup E''
inst✝⁷ : InnerProductSpace 𝕜' E''
inst✝⁶ : CompleteSpace E''
inst✝⁵ : NormedSpace ℝ E''
inst✝⁴ : NormedSpace ℝ G
hm : m ≤ m0
E : Type u_10
inst✝³ : NormedLatticeAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : OrderedSMul ℝ E
inst✝ : SigmaFinite (Measure.trim μ hm)
hs : MeasurableSet s
hμs : ↑↑μ s ≠ ⊤
x : E
hx : 0 ≤ x
⊢ 0 ≤ᵐ[μ] ↑↑(condexpIndSMul hm hs hμs x)

Next tactic:
refine' EventuallyLE.trans_eq _ (condexpIndSMul_ae_eq_smul hm hs hμs x).symm
theorem condexpIndSMul_nonneg {E} [NormedLatticeAddCommGroup E] [NormedSpace ℝ E] [OrderedSMul ℝ E]
    [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E) (hx : 0 ≤ x) :
    (0 : α → E) ≤ᵐ[μ] condexpIndSMul hm hs hμs x := by
  refine' EventuallyLE.trans_eq _ (condexpIndSMul_ae_eq_smul hm hs hμs x).symm
  

Proof state:
α : Type u_1
E✝ : Type u_2
E' : Type u_3
F : Type u_4
G : Type u_5
G' : Type u_6
𝕜 : Type u_7
p : ℝ≥0∞
inst✝²³ : IsROrC 𝕜
inst✝²² : NormedAddCommGroup E✝
inst✝²¹ : InnerProductSpace 𝕜 E✝
inst✝²⁰ : CompleteSpace E✝
inst✝¹⁹ : NormedAddCommGroup E'
inst✝¹⁸ : InnerProductSpace 𝕜 E'
inst✝¹⁷ : CompleteSpace E'
inst✝¹⁶ : NormedSpace ℝ E'
inst✝¹⁵ : NormedAddCommGroup F
inst✝¹⁴ : NormedSpace 𝕜 F
inst✝¹³ : NormedAddCommGroup G
inst✝¹² : NormedAddCommGroup G'
inst✝¹¹ : NormedSpace ℝ G'
inst✝¹⁰ : CompleteSpace G'
m m0 : MeasurableSpace α
μ : Measure α
s t : Set α
E'' : Type u_8
𝕜' : Type u_9
inst✝⁹ : IsROrC 𝕜'
inst✝⁸ : NormedAddCommGroup E''
inst✝⁷ : InnerProductSpace 𝕜' E''
inst✝⁶ : CompleteSpace E''
inst✝⁵ : NormedSpace ℝ E''
inst✝⁴ : NormedSpace ℝ G
hm : m ≤ m0
E : Type u_10
inst✝³ : NormedLatticeAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : OrderedSMul ℝ E
inst✝ : SigmaFinite (Measure.trim μ hm)
hs : MeasurableSet s
hμs : ↑↑μ s ≠ ⊤
x : E
hx : 0 ≤ x
⊢ 0 ≤ᵐ[μ] fun a => ↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1)) a • x

Next tactic:
filter_upwards [condexpL2_indicator_nonneg hm hs hμs] with a ha
theorem condexpIndSMul_nonneg {E} [NormedLatticeAddCommGroup E] [NormedSpace ℝ E] [OrderedSMul ℝ E]
    [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E) (hx : 0 ≤ x) :
    (0 : α → E) ≤ᵐ[μ] condexpIndSMul hm hs hμs x := by
  refine' EventuallyLE.trans_eq _ (condexpIndSMul_ae_eq_smul hm hs hμs x).symm
  filter_upwards [condexpL2_indicator_nonneg hm hs hμs] with a ha
  

Proof state:
case h
α : Type u_1
E✝ : Type u_2
E' : Type u_3
F : Type u_4
G : Type u_5
G' : Type u_6
𝕜 : Type u_7
p : ℝ≥0∞
inst✝²³ : IsROrC 𝕜
inst✝²² : NormedAddCommGroup E✝
inst✝²¹ : InnerProductSpace 𝕜 E✝
inst✝²⁰ : CompleteSpace E✝
inst✝¹⁹ : NormedAddCommGroup E'
inst✝¹⁸ : InnerProductSpace 𝕜 E'
inst✝¹⁷ : CompleteSpace E'
inst✝¹⁶ : NormedSpace ℝ E'
inst✝¹⁵ : NormedAddCommGroup F
inst✝¹⁴ : NormedSpace 𝕜 F
inst✝¹³ : NormedAddCommGroup G
inst✝¹² : NormedAddCommGroup G'
inst✝¹¹ : NormedSpace ℝ G'
inst✝¹⁰ : CompleteSpace G'
m m0 : MeasurableSpace α
μ : Measure α
s t : Set α
E'' : Type u_8
𝕜' : Type u_9
inst✝⁹ : IsROrC 𝕜'
inst✝⁸ : NormedAddCommGroup E''
inst✝⁷ : InnerProductSpace 𝕜' E''
inst✝⁶ : CompleteSpace E''
inst✝⁵ : NormedSpace ℝ E''
inst✝⁴ : NormedSpace ℝ G
hm : m ≤ m0
E : Type u_10
inst✝³ : NormedLatticeAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : OrderedSMul ℝ E
inst✝ : SigmaFinite (Measure.trim μ hm)
hs : MeasurableSet s
hμs : ↑↑μ s ≠ ⊤
x : E
hx : 0 ≤ x
a : α
ha : OfNat.ofNat 0 a ≤ ↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1)) a
⊢ OfNat.ofNat 0 a ≤ ↑↑↑((condexpL2 ℝ ℝ hm) (indicatorConstLp 2 hs hμs 1)) a • x

Next tactic:
exact smul_nonneg ha hx
@[simp]
theorem totient_one : φ 1 = 1 := by 

Proof state:
⊢ φ 1 = 1

Next tactic:
simp [totient]
/-- A characterisation of `Nat.totient` that avoids `Finset`. -/
theorem totient_eq_card_lt_and_coprime (n : ℕ) : φ n = Nat.card { m | m < n ∧ n.Coprime m } := by
  

Proof state:
n : ℕ
⊢ φ n = Nat.card ↑{m | m < n ∧ Coprime n m}

Next tactic:
let e : { m | m < n ∧ n.Coprime m } ≃ Finset.filter n.Coprime (Finset.range n) :=
    { toFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩
      invFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩
      left_inv := fun m => by simp only [Subtype.coe_mk, Subtype.coe_eta]
      right_inv := fun m => by simp only [Subtype.coe_mk, Subtype.coe_eta] }
/-- A characterisation of `Nat.totient` that avoids `Finset`. -/
theorem totient_eq_card_lt_and_coprime (n : ℕ) : φ n = Nat.card { m | m < n ∧ n.Coprime m } := by
  let e : { m | m < n ∧ n.Coprime m } ≃ Finset.filter n.Coprime (Finset.range n) :=
    { toFun := fun m => ⟨m, by 

Proof state:
n : ℕ
m : ↑{m | m < n ∧ Coprime n m}
⊢ ↑m ∈ filter (Coprime n) (range n)

Next tactic:
simpa only [Finset.mem_filter, Finset.mem_range] using m.property
/-- A characterisation of `Nat.totient` that avoids `Finset`. -/
theorem totient_eq_card_lt_and_coprime (n : ℕ) : φ n = Nat.card { m | m < n ∧ n.Coprime m } := by
  let e : { m | m < n ∧ n.Coprime m } ≃ Finset.filter n.Coprime (Finset.range n) :=
    { toFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩
      invFun := fun m => ⟨m, by 

Proof state:
n : ℕ
m : { x // x ∈ filter (Coprime n) (range n) }
⊢ ↑m ∈ {m | m < n ∧ Coprime n m}

Next tactic:
simpa only [Finset.mem_filter, Finset.mem_range] using m.property
/-- A characterisation of `Nat.totient` that avoids `Finset`. -/
theorem totient_eq_card_lt_and_coprime (n : ℕ) : φ n = Nat.card { m | m < n ∧ n.Coprime m } := by
  let e : { m | m < n ∧ n.Coprime m } ≃ Finset.filter n.Coprime (Finset.range n) :=
    { toFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩
      invFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩
      left_inv := fun m => by 

Proof state:
n : ℕ
m : ↑{m | m < n ∧ Coprime n m}
⊢ (fun m => { val := ↑m, property := (_ : ↑m < n ∧ Coprime n ↑m) })
      ((fun m => { val := ↑m, property := (_ : ↑m ∈ filter (Coprime n) (range n)) }) m) =
    m

Next tactic:
simp only [Subtype.coe_mk, Subtype.coe_eta]
/-- A characterisation of `Nat.totient` that avoids `Finset`. -/
theorem totient_eq_card_lt_and_coprime (n : ℕ) : φ n = Nat.card { m | m < n ∧ n.Coprime m } := by
  let e : { m | m < n ∧ n.Coprime m } ≃ Finset.filter n.Coprime (Finset.range n) :=
    { toFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩
      invFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩
      left_inv := fun m => by simp only [Subtype.coe_mk, Subtype.coe_eta]
      right_inv := fun m => by 

Proof state:
n : ℕ
m : { x // x ∈ filter (Coprime n) (range n) }
⊢ (fun m => { val := ↑m, property := (_ : ↑m ∈ filter (Coprime n) (range n)) })
      ((fun m => { val := ↑m, property := (_ : ↑m < n ∧ Coprime n ↑m) }) m) =
    m

Next tactic:
simp only [Subtype.coe_mk, Subtype.coe_eta]
/-- A characterisation of `Nat.totient` that avoids `Finset`. -/
theorem totient_eq_card_lt_and_coprime (n : ℕ) : φ n = Nat.card { m | m < n ∧ n.Coprime m } := by
  let e : { m | m < n ∧ n.Coprime m } ≃ Finset.filter n.Coprime (Finset.range n) :=
    { toFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩
      invFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩
      left_inv := fun m => by simp only [Subtype.coe_mk, Subtype.coe_eta]
      right_inv := fun m => by simp only [Subtype.coe_mk, Subtype.coe_eta] }
  

Proof state:
n : ℕ
e : ↑{m | m < n ∧ Coprime n m} ≃ { x // x ∈ filter (Coprime n) (range n) } :=
  { toFun := fun m => { val := ↑m, property := (_ : ↑m ∈ filter (Coprime n) (range n)) },
    invFun := fun m => { val := ↑m, property := (_ : ↑m < n ∧ Coprime n ↑m) },
    left_inv :=
      (_ :
        ∀ (m : ↑{m | m < n ∧ Coprime n m}),
          { val := ↑m,
              property :=
                (_ :
                  ↑((fun m => { val := ↑m, property := (_ : ↑m ∈ filter (Coprime n) (range n)) }) m) < n ∧
                    Coprime n ↑((fun m => { val := ↑m, property := (_ : ↑m ∈ filter (Coprime n) (range n)) }) m)) } =
            m),
    right_inv :=
      (_ :
        ∀ (m : { x // x ∈ filter (Coprime n) (range n) }),
          { val := ↑m,
              property :=
                (_ :
                  ↑((fun m => { val := ↑m, property := (_ : ↑m < n ∧ Coprime n ↑m) }) m) ∈
                    filter (Coprime n) (range n)) } =
            m) }
⊢ φ n = Nat.card ↑{m | m < n ∧ Coprime n m}

Next tactic:
rw [totient_eq_card_coprime, card_congr e, card_eq_fintype_card, Fintype.card_coe]
theorem totient_lt (n : ℕ) (hn : 1 < n) : φ n < n :=
  (card_lt_card (filter_ssubset.2 ⟨0, by 

Proof state:
n : ℕ
hn : 1 < n
⊢ 0 ∈ range n ∧ ¬Coprime n 0

Next tactic:
simp [hn.ne', pos_of_gt hn]
theorem totient_pos : ∀ {n : ℕ}, 0 < n → 0 < φ n
  | 0 => by 

Proof state:
⊢ 0 < 0 → 0 < φ 0

Next tactic:
decide
theorem totient_pos : ∀ {n : ℕ}, 0 < n → 0 < φ n
  | 0 => by decide
  | 1 => by 

Proof state:
⊢ 0 < 1 → 0 < φ 1

Next tactic:
simp [totient]
theorem totient_pos : ∀ {n : ℕ}, 0 < n → 0 < φ n
  | 0 => by decide
  | 1 => by simp [totient]
  | n + 2 => fun _ =>
  -- Must qualify `Finset.card_pos` because of leanprover/lean4#2849
    Finset.card_pos.2 ⟨1, mem_filter.2 ⟨mem_range.2 (by 

Proof state:
n : ℕ
x✝ : 0 < n + 2
⊢ 1 < n + 2

Next tactic:
simp
theorem filter_coprime_Ico_eq_totient (a n : ℕ) :
    ((Ico n (n + a)).filter (Coprime a)).card = totient a := by
  

Proof state:
a n : ℕ
⊢ card (filter (Coprime a) (Ico n (n + a))) = φ a

Next tactic:
rw [totient, filter_Ico_card_eq_of_periodic, count_eq_card_filter_range]
theorem filter_coprime_Ico_eq_totient (a n : ℕ) :
    ((Ico n (n + a)).filter (Coprime a)).card = totient a := by
  rw [totient, filter_Ico_card_eq_of_periodic, count_eq_card_filter_range]
  

Proof state:
case pp
a n : ℕ
⊢ Function.Periodic (Coprime a) a

Next tactic:
exact periodic_coprime a
theorem Ico_filter_coprime_le {a : ℕ} (k n : ℕ) (a_pos : 0 < a) :
    ((Ico k (k + n)).filter (Coprime a)).card ≤ totient a * (n / a + 1) := by
  

Proof state:
a k n : ℕ
a_pos : 0 < a
⊢ card (filter (Coprime a) (Ico k (k + n))) ≤ φ a * (n / a + 1)

Next tactic:
conv_lhs => rw [← Nat.mod_add_div n a]
theorem Ico_filter_coprime_le {a : ℕ} (k n : ℕ) (a_pos : 0 < a) :
    ((Ico k (k + n)).filter (Coprime a)).card ≤ totient a * (n / a + 1) := by
  conv_lhs => 

Proof state:
a k n : ℕ
a_pos : 0 < a
| card (filter (Coprime a) (Ico k (k + n)))

Next tactic:
rw [← Nat.mod_add_div n a]
theorem Ico_filter_coprime_le {a : ℕ} (k n : ℕ) (a_pos : 0 < a) :
    ((Ico k (k + n)).filter (Coprime a)).card ≤ totient a * (n / a + 1) := by
  conv_lhs => rw [← Nat.mod_add_div n a]
  

Proof state:
a k n : ℕ
a_pos : 0 < a
⊢ card (filter (Coprime a) (Ico k (k + (n % a + a * (n / a))))) ≤ φ a * (n / a + 1)

Next tactic:
induction' n / a with i ih
theorem Ico_filter_coprime_le {a : ℕ} (k n : ℕ) (a_pos : 0 < a) :
    ((Ico k (k + n)).filter (Coprime a)).card ≤ totient a * (n / a + 1) := by
  conv_lhs => rw [← Nat.mod_add_div n a]
  induction' n / a with i ih
  · 

Proof state:
case zero
a k n : ℕ
a_pos : 0 < a
⊢ card (filter (Coprime a) (Ico k (k + (n % a + a * zero)))) ≤ φ a * (zero + 1)

Next tactic:
rw [← filter_coprime_Ico_eq_totient a k]
theorem Ico_filter_coprime_le {a : ℕ} (k n : ℕ) (a_pos : 0 < a) :
    ((Ico k (k + n)).filter (Coprime a)).card ≤ totient a * (n / a + 1) := by
  conv_lhs => rw [← Nat.mod_add_div n a]
  induction' n / a with i ih
  · rw [← filter_coprime_Ico_eq_totient a k]
    

Proof state:
case zero
a k n : ℕ
a_pos : 0 < a
⊢ card (filter (Coprime a) (Ico k (k + (n % a + a * zero)))) ≤ card (filter (Coprime a) (Ico k (k + a))) * (zero + 1)

Next tactic:
simp only [add_zero, mul_one, mul_zero, le_of_lt (mod_lt n a_pos),
      Nat.zero_eq, zero_add]