l3lab/ntp-mathlib huggingface dataset:
/-- **Fundamental theorem of calculus-1**, local version for any measure.
Let filters `l` and `l'` be related by `TendstoIxxClass Ioc`.
If `f` has a finite limit `c` at `l' ⊓ μ.ae`, where `μ` is a measure
finite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both
`u` and `v` tend to `l`.

See also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming
`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one
of `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version.  The primed version
also works, e.g., for `l = l' = atTop`.

We use integrals of constants instead of measures because this way it is easier to formulate
a statement that works in both cases `u ≤ v` and `v ≤ u`. -/
theorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']
    [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)
    (hf : Tendsto f (l' ⊓ μ.ae) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)
    (hv : Tendsto v lt l) :
    (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>
      ∫ _ in u t..v t, (1 : ℝ) ∂μ := by
  by_cases hE : CompleteSpace E; 

Proof state:
case pos
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : CompleteSpace E
⊢ (fun t => ∫ (x : ℝ) in u t..v t, f x ∂μ - ∫ (x : ℝ) in u t..v t, c ∂μ) =o[lt] fun t => ∫ (x : ℝ) in u t..v t, 1 ∂μ
case neg
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : ¬CompleteSpace E
⊢ (fun t => ∫ (x : ℝ) in u t..v t, f x ∂μ - ∫ (x : ℝ) in u t..v t, c ∂μ) =o[lt] fun t => ∫ (x : ℝ) in u t..v t, 1 ∂μ

Next tactic:
swap
/-- **Fundamental theorem of calculus-1**, local version for any measure.
Let filters `l` and `l'` be related by `TendstoIxxClass Ioc`.
If `f` has a finite limit `c` at `l' ⊓ μ.ae`, where `μ` is a measure
finite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both
`u` and `v` tend to `l`.

See also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming
`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one
of `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version.  The primed version
also works, e.g., for `l = l' = atTop`.

We use integrals of constants instead of measures because this way it is easier to formulate
a statement that works in both cases `u ≤ v` and `v ≤ u`. -/
theorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']
    [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)
    (hf : Tendsto f (l' ⊓ μ.ae) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)
    (hv : Tendsto v lt l) :
    (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>
      ∫ _ in u t..v t, (1 : ℝ) ∂μ := by
  by_cases hE : CompleteSpace E; swap
  · 

Proof state:
case neg
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : ¬CompleteSpace E
⊢ (fun t => ∫ (x : ℝ) in u t..v t, f x ∂μ - ∫ (x : ℝ) in u t..v t, c ∂μ) =o[lt] fun t => ∫ (x : ℝ) in u t..v t, 1 ∂μ

Next tactic:
simp [intervalIntegral, integral, hE]
/-- **Fundamental theorem of calculus-1**, local version for any measure.
Let filters `l` and `l'` be related by `TendstoIxxClass Ioc`.
If `f` has a finite limit `c` at `l' ⊓ μ.ae`, where `μ` is a measure
finite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both
`u` and `v` tend to `l`.

See also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming
`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one
of `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version.  The primed version
also works, e.g., for `l = l' = atTop`.

We use integrals of constants instead of measures because this way it is easier to formulate
a statement that works in both cases `u ≤ v` and `v ≤ u`. -/
theorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']
    [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)
    (hf : Tendsto f (l' ⊓ μ.ae) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)
    (hv : Tendsto v lt l) :
    (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>
      ∫ _ in u t..v t, (1 : ℝ) ∂μ := by
  by_cases hE : CompleteSpace E; swap
  · simp [intervalIntegral, integral, hE]
  

Proof state:
case pos
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : CompleteSpace E
⊢ (fun t => ∫ (x : ℝ) in u t..v t, f x ∂μ - ∫ (x : ℝ) in u t..v t, c ∂μ) =o[lt] fun t => ∫ (x : ℝ) in u t..v t, 1 ∂μ

Next tactic:
have A := hf.integral_sub_linear_isLittleO_ae hfm hl (hu.Ioc hv)
/-- **Fundamental theorem of calculus-1**, local version for any measure.
Let filters `l` and `l'` be related by `TendstoIxxClass Ioc`.
If `f` has a finite limit `c` at `l' ⊓ μ.ae`, where `μ` is a measure
finite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both
`u` and `v` tend to `l`.

See also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming
`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one
of `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version.  The primed version
also works, e.g., for `l = l' = atTop`.

We use integrals of constants instead of measures because this way it is easier to formulate
a statement that works in both cases `u ≤ v` and `v ≤ u`. -/
theorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']
    [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)
    (hf : Tendsto f (l' ⊓ μ.ae) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)
    (hv : Tendsto v lt l) :
    (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>
      ∫ _ in u t..v t, (1 : ℝ) ∂μ := by
  by_cases hE : CompleteSpace E; swap
  · simp [intervalIntegral, integral, hE]
  have A := hf.integral_sub_linear_isLittleO_ae hfm hl (hu.Ioc hv)
  

Proof state:
case pos
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A✝ : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : CompleteSpace E
A :
  (fun i => ∫ (x : ℝ) in Ioc (u i) (v i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (u i) (v i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (u i) (v i)))
⊢ (fun t => ∫ (x : ℝ) in u t..v t, f x ∂μ - ∫ (x : ℝ) in u t..v t, c ∂μ) =o[lt] fun t => ∫ (x : ℝ) in u t..v t, 1 ∂μ

Next tactic:
have B := hf.integral_sub_linear_isLittleO_ae hfm hl (hv.Ioc hu)
/-- **Fundamental theorem of calculus-1**, local version for any measure.
Let filters `l` and `l'` be related by `TendstoIxxClass Ioc`.
If `f` has a finite limit `c` at `l' ⊓ μ.ae`, where `μ` is a measure
finite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both
`u` and `v` tend to `l`.

See also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming
`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one
of `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version.  The primed version
also works, e.g., for `l = l' = atTop`.

We use integrals of constants instead of measures because this way it is easier to formulate
a statement that works in both cases `u ≤ v` and `v ≤ u`. -/
theorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']
    [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)
    (hf : Tendsto f (l' ⊓ μ.ae) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)
    (hv : Tendsto v lt l) :
    (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>
      ∫ _ in u t..v t, (1 : ℝ) ∂μ := by
  by_cases hE : CompleteSpace E; swap
  · simp [intervalIntegral, integral, hE]
  have A := hf.integral_sub_linear_isLittleO_ae hfm hl (hu.Ioc hv)
  have B := hf.integral_sub_linear_isLittleO_ae hfm hl (hv.Ioc hu)
  

Proof state:
case pos
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A✝ : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : CompleteSpace E
A :
  (fun i => ∫ (x : ℝ) in Ioc (u i) (v i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (u i) (v i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (u i) (v i)))
B :
  (fun i => ∫ (x : ℝ) in Ioc (v i) (u i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (v i) (u i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (v i) (u i)))
⊢ (fun t => ∫ (x : ℝ) in u t..v t, f x ∂μ - ∫ (x : ℝ) in u t..v t, c ∂μ) =o[lt] fun t => ∫ (x : ℝ) in u t..v t, 1 ∂μ

Next tactic:
simp_rw [integral_const', sub_smul]
/-- **Fundamental theorem of calculus-1**, local version for any measure.
Let filters `l` and `l'` be related by `TendstoIxxClass Ioc`.
If `f` has a finite limit `c` at `l' ⊓ μ.ae`, where `μ` is a measure
finite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both
`u` and `v` tend to `l`.

See also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming
`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one
of `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version.  The primed version
also works, e.g., for `l = l' = atTop`.

We use integrals of constants instead of measures because this way it is easier to formulate
a statement that works in both cases `u ≤ v` and `v ≤ u`. -/
theorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']
    [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)
    (hf : Tendsto f (l' ⊓ μ.ae) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)
    (hv : Tendsto v lt l) :
    (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>
      ∫ _ in u t..v t, (1 : ℝ) ∂μ := by
  by_cases hE : CompleteSpace E; swap
  · simp [intervalIntegral, integral, hE]
  have A := hf.integral_sub_linear_isLittleO_ae hfm hl (hu.Ioc hv)
  have B := hf.integral_sub_linear_isLittleO_ae hfm hl (hv.Ioc hu)
  simp_rw [integral_const', sub_smul]
  

Proof state:
case pos
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A✝ : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : CompleteSpace E
A :
  (fun i => ∫ (x : ℝ) in Ioc (u i) (v i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (u i) (v i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (u i) (v i)))
B :
  (fun i => ∫ (x : ℝ) in Ioc (v i) (u i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (v i) (u i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (v i) (u i)))
⊢ (fun t =>
      ∫ (x : ℝ) in u t..v t, f x ∂μ -
        (ENNReal.toReal (↑↑μ (Ioc (u t) (v t))) • c - ENNReal.toReal (↑↑μ (Ioc (v t) (u t))) • c)) =o[lt]
    fun t => ENNReal.toReal (↑↑μ (Ioc (u t) (v t))) • 1 - ENNReal.toReal (↑↑μ (Ioc (v t) (u t))) • 1

Next tactic:
refine ((A.trans_le fun t ↦ ?_).sub (B.trans_le fun t ↦ ?_)).congr_left fun t ↦ ?_
/-- **Fundamental theorem of calculus-1**, local version for any measure.
Let filters `l` and `l'` be related by `TendstoIxxClass Ioc`.
If `f` has a finite limit `c` at `l' ⊓ μ.ae`, where `μ` is a measure
finite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both
`u` and `v` tend to `l`.

See also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming
`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one
of `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version.  The primed version
also works, e.g., for `l = l' = atTop`.

We use integrals of constants instead of measures because this way it is easier to formulate
a statement that works in both cases `u ≤ v` and `v ≤ u`. -/
theorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']
    [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)
    (hf : Tendsto f (l' ⊓ μ.ae) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)
    (hv : Tendsto v lt l) :
    (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>
      ∫ _ in u t..v t, (1 : ℝ) ∂μ := by
  by_cases hE : CompleteSpace E; swap
  · simp [intervalIntegral, integral, hE]
  have A := hf.integral_sub_linear_isLittleO_ae hfm hl (hu.Ioc hv)
  have B := hf.integral_sub_linear_isLittleO_ae hfm hl (hv.Ioc hu)
  simp_rw [integral_const', sub_smul]
  refine ((A.trans_le fun t ↦ ?_).sub (B.trans_le fun t ↦ ?_)).congr_left fun t ↦ ?_
  · 

Proof state:
case pos.refine_1
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A✝ : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : CompleteSpace E
A :
  (fun i => ∫ (x : ℝ) in Ioc (u i) (v i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (u i) (v i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (u i) (v i)))
B :
  (fun i => ∫ (x : ℝ) in Ioc (v i) (u i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (v i) (u i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (v i) (u i)))
t : ι
⊢ ‖ENNReal.toReal (↑↑μ (Ioc (u t) (v t)))‖ ≤
    ‖ENNReal.toReal (↑↑μ (Ioc (u t) (v t))) • 1 - ENNReal.toReal (↑↑μ (Ioc (v t) (u t))) • 1‖

Next tactic:
cases le_total (u t) (v t)
/-- **Fundamental theorem of calculus-1**, local version for any measure.
Let filters `l` and `l'` be related by `TendstoIxxClass Ioc`.
If `f` has a finite limit `c` at `l' ⊓ μ.ae`, where `μ` is a measure
finite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both
`u` and `v` tend to `l`.

See also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming
`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one
of `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version.  The primed version
also works, e.g., for `l = l' = atTop`.

We use integrals of constants instead of measures because this way it is easier to formulate
a statement that works in both cases `u ≤ v` and `v ≤ u`. -/
theorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']
    [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)
    (hf : Tendsto f (l' ⊓ μ.ae) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)
    (hv : Tendsto v lt l) :
    (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>
      ∫ _ in u t..v t, (1 : ℝ) ∂μ := by
  by_cases hE : CompleteSpace E; swap
  · simp [intervalIntegral, integral, hE]
  have A := hf.integral_sub_linear_isLittleO_ae hfm hl (hu.Ioc hv)
  have B := hf.integral_sub_linear_isLittleO_ae hfm hl (hv.Ioc hu)
  simp_rw [integral_const', sub_smul]
  refine ((A.trans_le fun t ↦ ?_).sub (B.trans_le fun t ↦ ?_)).congr_left fun t ↦ ?_
  · cases le_total (u t) (v t) <;> 

Proof state:
case pos.refine_1.inl
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A✝ : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : CompleteSpace E
A :
  (fun i => ∫ (x : ℝ) in Ioc (u i) (v i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (u i) (v i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (u i) (v i)))
B :
  (fun i => ∫ (x : ℝ) in Ioc (v i) (u i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (v i) (u i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (v i) (u i)))
t : ι
h✝ : u t ≤ v t
⊢ ‖ENNReal.toReal (↑↑μ (Ioc (u t) (v t)))‖ ≤
    ‖ENNReal.toReal (↑↑μ (Ioc (u t) (v t))) • 1 - ENNReal.toReal (↑↑μ (Ioc (v t) (u t))) • 1‖

Next tactic:
simp [*]
/-- **Fundamental theorem of calculus-1**, local version for any measure.
Let filters `l` and `l'` be related by `TendstoIxxClass Ioc`.
If `f` has a finite limit `c` at `l' ⊓ μ.ae`, where `μ` is a measure
finite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both
`u` and `v` tend to `l`.

See also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming
`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one
of `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version.  The primed version
also works, e.g., for `l = l' = atTop`.

We use integrals of constants instead of measures because this way it is easier to formulate
a statement that works in both cases `u ≤ v` and `v ≤ u`. -/
theorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']
    [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)
    (hf : Tendsto f (l' ⊓ μ.ae) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)
    (hv : Tendsto v lt l) :
    (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>
      ∫ _ in u t..v t, (1 : ℝ) ∂μ := by
  by_cases hE : CompleteSpace E; swap
  · simp [intervalIntegral, integral, hE]
  have A := hf.integral_sub_linear_isLittleO_ae hfm hl (hu.Ioc hv)
  have B := hf.integral_sub_linear_isLittleO_ae hfm hl (hv.Ioc hu)
  simp_rw [integral_const', sub_smul]
  refine ((A.trans_le fun t ↦ ?_).sub (B.trans_le fun t ↦ ?_)).congr_left fun t ↦ ?_
  · cases le_total (u t) (v t) <;> 

Proof state:
case pos.refine_1.inr
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A✝ : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : CompleteSpace E
A :
  (fun i => ∫ (x : ℝ) in Ioc (u i) (v i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (u i) (v i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (u i) (v i)))
B :
  (fun i => ∫ (x : ℝ) in Ioc (v i) (u i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (v i) (u i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (v i) (u i)))
t : ι
h✝ : v t ≤ u t
⊢ ‖ENNReal.toReal (↑↑μ (Ioc (u t) (v t)))‖ ≤
    ‖ENNReal.toReal (↑↑μ (Ioc (u t) (v t))) • 1 - ENNReal.toReal (↑↑μ (Ioc (v t) (u t))) • 1‖

Next tactic:
simp [*]
/-- **Fundamental theorem of calculus-1**, local version for any measure.
Let filters `l` and `l'` be related by `TendstoIxxClass Ioc`.
If `f` has a finite limit `c` at `l' ⊓ μ.ae`, where `μ` is a measure
finite at `l'`, then `∫ x in u..v, f x ∂μ = ∫ x in u..v, c ∂μ + o(∫ x in u..v, 1 ∂μ)` as both
`u` and `v` tend to `l`.

See also `measure_integral_sub_linear_isLittleO_of_tendsto_ae` for a version assuming
`[intervalIntegral.FTCFilter a l l']` and `[MeasureTheory.IsLocallyFiniteMeasure μ]`. If `l` is one
of `𝓝[≥] a`, `𝓝[≤] a`, `𝓝 a`, then it's easier to apply the non-primed version.  The primed version
also works, e.g., for `l = l' = atTop`.

We use integrals of constants instead of measures because this way it is easier to formulate
a statement that works in both cases `u ≤ v` and `v ≤ u`. -/
theorem measure_integral_sub_linear_isLittleO_of_tendsto_ae' [IsMeasurablyGenerated l']
    [TendstoIxxClass Ioc l l'] (hfm : StronglyMeasurableAtFilter f l' μ)
    (hf : Tendsto f (l' ⊓ μ.ae) (𝓝 c)) (hl : μ.FiniteAtFilter l') (hu : Tendsto u lt l)
    (hv : Tendsto v lt l) :
    (fun t => (∫ x in u t..v t, f x ∂μ) - ∫ _ in u t..v t, c ∂μ) =o[lt] fun t =>
      ∫ _ in u t..v t, (1 : ℝ) ∂μ := by
  by_cases hE : CompleteSpace E; swap
  · simp [intervalIntegral, integral, hE]
  have A := hf.integral_sub_linear_isLittleO_ae hfm hl (hu.Ioc hv)
  have B := hf.integral_sub_linear_isLittleO_ae hfm hl (hv.Ioc hu)
  simp_rw [integral_const', sub_smul]
  refine ((A.trans_le fun t ↦ ?_).sub (B.trans_le fun t ↦ ?_)).congr_left fun t ↦ ?_
  · cases le_total (u t) (v t) <;> simp [*]
  · 

Proof state:
case pos.refine_2
ι : Type u_1
𝕜 : Type u_2
E : Type u_3
F : Type u_4
A✝ : Type u_5
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
c ca cb : E
l l' la la' lb lb' : Filter ℝ
lt : Filter ι
μ : Measure ℝ
u v ua va ub vb : ι → ℝ
inst✝¹ : IsMeasurablyGenerated l'
inst✝ : TendstoIxxClass Ioc l l'
hfm : StronglyMeasurableAtFilter f l'
hf : Tendsto f (l' ⊓ Measure.ae μ) (𝓝 c)
hl : Measure.FiniteAtFilter μ l'
hu : Tendsto u lt l
hv : Tendsto v lt l
hE : CompleteSpace E
A :
  (fun i => ∫ (x : ℝ) in Ioc (u i) (v i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (u i) (v i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (u i) (v i)))
B :
  (fun i => ∫ (x : ℝ) in Ioc (v i) (u i), f x ∂μ - ENNReal.toReal (↑↑μ (Ioc (v i) (u i))) • c) =o[lt] fun i =>
    ENNReal.toReal (↑↑μ (Ioc (v i) (u i)))
t : ι
⊢ ‖ENNReal.toReal (↑↑μ (Ioc (v t) (u t)))‖ ≤
    ‖ENNReal.toReal (↑↑μ (Ioc (u t) (v t))) • 1 - ENNReal.toReal (↑↑μ (Ioc (v t) (u t))) • 1‖

Next tactic:
cases le_total (u t) (v t)