-- Lean 4 proof step from Mathlib.Analysis.BoxIntegral.DivergenceTheorem (goal)
Goal:
E : Type u
inst : NormedAddCommGroup E
inst_1 : NormedSpace ℝ E
n : ℕ
inst_2 : CompleteSpace E
I : Box (Fin (n + 1))
f : (Fin (n + 1) → ℝ) → E
f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] E
s : Set (Fin (n + 1) → ℝ)
hs : s.Countable
Hs : ∀ x ∈ s, ContinuousWithinAt f ((Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I) x
Hd :
  ∀ (x : Fin (n + 1) → ℝ),
    Membership.mem (γ := Set (Fin (n + 1) → ℝ))
        ((Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I \ s : Set (Fin (n + 1) → ℝ)) x →
      HasFDerivWithinAt f (f' x) ((Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I) x
i : Fin (n + 1)
Hc : ContinuousOn f ((Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I)
fI : ℝ → Box (Fin n) → E :=
  fun (y : ℝ) (J : Box (Fin n)) ↦
    integral J GP (fun (x : Fin n → ℝ) ↦ f (i.insertNth (α := fun (a : Fin (n + 1)) ↦ ℝ) y x)) BoxAdditiveMap.volume
fb : (↑(Set.Icc (I.lower i) (I.upper i)) : Type) → Fin n →ᵇᵃ[(↑(I.face i) : WithTop (Box (Fin n)))] E :=
  fun (x : (↑(Set.Icc (I.lower i) (I.upper i)) : Type)) ↦
    Integrable.toBoxAdditive (vol := BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) ⋯
F : Fin (n + 1) →ᵇᵃ[(↑I : WithTop (Box (Fin (n + 1))))] E := BoxAdditiveMap.upperSubLower I i fI fb ⋯
c : ℝ≥0
x : Fin (n + 1) → ℝ
hx :
  Membership.mem (γ := Set (Fin (n + 1) → ℝ))
    ((Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I ∩ s : Set (Fin (n + 1) → ℝ)) x
ε : ℝ
ε0 : ε > 0
this :
  ∀ᶠ (δ : ℝ) in 𝓝[>] 0,
    δ ∈ Set.Ioc 0 (1 / 2) ∧
      (∀ y₁ ∈ closedBall x δ ∩ (Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I,
          ∀ y₂ ∈ closedBall x δ ∩ (Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I,
            ‖f y₁ - f y₂‖ ≤ ε / 2) ∧
        (2 * δ) ^ (n + 1) *
            norm (E := E) ((f' x : (a : Fin (n + 1) → ℝ) → E) (Pi.single (M := fun (a : Fin (n + 1)) ↦ ℝ) i 1) : E) ≤
          ε / 2
δ : ℝ
hδ0 : 0 < δ
hδ12 : δ ≤ 1 / 2
hdfδ :
  ∀ y₁ ∈ closedBall x δ ∩ (Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I,
    ∀ y₂ ∈ closedBall x δ ∩ (Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I, ‖f y₁ - f y₂‖ ≤ ε / 2
hδ :
  (2 * δ) ^ (n + 1) *
      norm (E := E) ((f' x : (a : Fin (n + 1) → ℝ) → E) (Pi.single (M := fun (a : Fin (n + 1)) ↦ ℝ) i 1) : E) ≤
    ε / 2
J : Box (Fin (n + 1))
hJI : J ≤ I
hJδ : (Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) J ⊆ closedBall x δ
h :
  Membership.mem (γ := Set (Fin (n + 1) → ℝ))
    ((Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) J : Set (Fin (n + 1) → ℝ)) x
h_1 : GP.bDistortion = true → J.distortion ≤ c
Hl : J.lower i ∈ Set.Icc (J.lower i) (J.upper i)
Hu : J.upper i ∈ Set.Icc (J.lower i) (J.upper i)
Hi :
  ∀ x ∈ Set.Icc (J.lower i) (J.upper i),
    Integrable.{0, u, u} (E := E) (J.face i) GP
      (fun (y : Fin n → ℝ) ↦ f (i.insertNth (α := fun (a : Fin (n + 1)) ↦ ℝ) x y)) BoxAdditiveMap.volume
hJδ' :
  (Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) J ⊆
    closedBall x δ ∩ (Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I
Hmaps :
  ∀ z ∈ Set.Icc (J.lower i) (J.upper i),
    MapsTo (i.insertNth (α := fun (j : Fin (n + 1)) ↦ ℝ) z) ((Box.Icc : (a : Box (Fin n)) → Set (Fin n → ℝ)) (J.face i))
      (closedBall x δ ∩ (Box.Icc : (a : Box (Fin (n + 1))) → Set (Fin (n + 1) → ℝ)) I)
j : Fin n
h_2 : Membership.mem (γ := Finset (Fin n)) Finset.univ j
⊢ (J.face i).upper j - (J.face i).lower j ≤ 1
have dist : δ + δ ≤ 1 / 2 + 1 / 2
Tactic: calc
        J.upper (i.succAbove j) - J.lower (i.succAbove j) ≤
            dist (J.upper (i.succAbove j)) (J.lower (i.succAbove j)) :=
          le_abs_self _
        _ ≤ dist J.upper J.lower := dist_le_pi_dist J.upper J.lower (i.succAbove j)
        _ ≤ dist J.upper x + dist J.lower x := dist_triangle_right _ _ _
        _ ≤ δ + δ := add_le_add (hJδ J.upper_mem_Icc) (hJδ J.lower_mem_Icc)
        _ ≤ 1 / 2 + 1 / 2 := by gcongr
        _ = 1 := add_halves 1