Theorem: MeasureTheory.integral_eq_of_hasDerivWithinAt_off_countable_of_le
File: Mathlib/MeasureTheory/Integral/DivergenceTheorem.lean

tactic: set e : ℝ ≃L[ℝ] ℝ¹ := (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ).symm
state_before: E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x
Hi : IntervalIntegrable f' volume a b
⊢ (∫ (x : ℝ) in a..b, f' x) = f b - f a

tactic: have e_symm : ∀ x, e.symm x = x 0 := fun x => rfl
state_before: E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
⊢ (∫ (x : ℝ) in a..b, f' x) = f b - f a

tactic: set F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight (1 : ℝ →L[ℝ] ℝ) (f' x)
state_before: E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
⊢ (∫ (x : ℝ) in a..b, f' x) = f b - f a

tactic: have hF' : ∀ x y, F' x y = y • f' x := fun x y => rfl
state_before: E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
⊢ (∫ (x : ℝ) in a..b, f' x) = f b - f a

tactic: rw [intervalIntegral.integral_of_le hle, set_integral_congr_set_ae Ioc_ae_eq_Icc]
state_before: E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
⊢ (∫ (x : ℝ) in a..b, f' x) = ∫ (x : ℝ) in Set.Icc a b, f' x

tactic: simp only [← interior_Icc] at Hd
state_before: E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
⊢ (∫ (x : ℝ) in Set.Icc a b, f' x) =
    ∑ i : Fin 1,
      ((∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ ↑(Fin.succAbove i)) (↑e b ∘ ↑(Fin.succAbove i)),
          f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e b i) x))) -
        ∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ ↑(Fin.succAbove i)) (↑e b ∘ ↑(Fin.succAbove i)),
          f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e a i) x)))

tactic: refine'
  integral_divergence_of_hasFDerivWithinAt_off_countable_of_equiv e _ _ (fun _ => f)
    (fun _ => F') s hs a b hle (fun _ => Hc) (fun x hx _ => Hd x hx) _ _ _
state_before: E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x
⊢ (∫ (x : ℝ) in Set.Icc a b, f' x) =
    ∑ i : Fin 1,
      ((∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ ↑(Fin.succAbove i)) (↑e b ∘ ↑(Fin.succAbove i)),
          f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e b i) x))) -
        ∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ ↑(Fin.succAbove i)) (↑e b ∘ ↑(Fin.succAbove i)),
          f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e a i) x)))

tactic: exact fun x y => (OrderIso.funUnique (Fin 1) ℝ).symm.le_iff_le
state_before: case refine'_1
E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x
⊢ ∀ (x y : ℝ), ↑e x ≤ ↑e y ↔ x ≤ y

tactic: exact (volume_preserving_funUnique (Fin 1) ℝ).symm _
state_before: case refine'_2
E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x
⊢ MeasurePreserving ↑e

tactic: intro x
state_before: case refine'_3
E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x
⊢ ∀ (x : ℝ), f' x = ∑ i : Fin (0 + 1), ↑((fun x => F') i x) (↑(ContinuousLinearEquiv.symm e) (Pi.single i 1))

tactic: rw [Fin.sum_univ_one, hF', e_symm, Pi.single_eq_same, one_smul]
state_before: case refine'_3
E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x
x : ℝ
⊢ f' x = ∑ i : Fin (0 + 1), ↑((fun x => F') i x) (↑(ContinuousLinearEquiv.symm e) (Pi.single i 1))

tactic: rw [intervalIntegrable_iff_integrable_Ioc_of_le hle] at Hi
state_before: case refine'_4
E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x
⊢ IntegrableOn (fun x => f' x) (Set.Icc a b)

tactic: exact Hi.congr_set_ae Ioc_ae_eq_Icc.symm
state_before: case refine'_4
E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hi : IntegrableOn f' (Set.Ioc a b)
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x
⊢ IntegrableOn (fun x => f' x) (Set.Icc a b)

tactic: simp only [Fin.sum_univ_one, e_symm]
state_before: E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
⊢ ∑ i : Fin 1,
      ((∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ ↑(Fin.succAbove i)) (↑e b ∘ ↑(Fin.succAbove i)),
          f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e b i) x))) -
        ∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ ↑(Fin.succAbove i)) (↑e b ∘ ↑(Fin.succAbove i)),
          f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e a i) x))) =
    f b - f a

tactic: have : ∀ c : ℝ, const (Fin 0) c = isEmptyElim := fun c => Subsingleton.elim _ _
state_before: E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
⊢ ((∫ (x : Fin 0 → ℝ) in
        Set.Icc (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a ∘ ↑(Fin.succAbove 0))
          (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b ∘ ↑(Fin.succAbove 0)),
        f (Fin.insertNth 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b 0) x 0)) -
      ∫ (x : Fin 0 → ℝ) in
        Set.Icc (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a ∘ ↑(Fin.succAbove 0))
          (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b ∘ ↑(Fin.succAbove 0)),
        f (Fin.insertNth 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a 0) x 0)) =
    f b - f a

tactic: simp [this, volume_pi, Measure.pi_of_empty fun _ : Fin 0 => volume]
state_before: E : Type u
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f f' : ℝ → E
a b : ℝ
hle : a ≤ b
s : Set ℝ
hs : Set.Countable s
Hc : ContinuousOn f (Set.Icc a b)
Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x
Hi : IntervalIntegrable f' volume a b
e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)
e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0
F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x)
hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x
this : ∀ (c : ℝ), const (Fin 0) c = fun a => isEmptyElim a
⊢ ((∫ (x : Fin 0 → ℝ) in
        Set.Icc (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a ∘ ↑(Fin.succAbove 0))
          (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b ∘ ↑(Fin.succAbove 0)),
        f (Fin.insertNth 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b 0) x 0)) -
      ∫ (x : Fin 0 → ℝ) in
        Set.Icc (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a ∘ ↑(Fin.succAbove 0))
          (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b ∘ ↑(Fin.succAbove 0)),
        f (Fin.insertNth 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a 0) x 0)) =
    f b - f a