/-- Given a box `I₀` in `ℝⁿ⁺¹`, `f x : Box (Fin n) → G` is a family of functions indexed by a real
`x` and for `x ∈ [I₀.lower i, I₀.upper i]`, `f x` is box-additive on subboxes of the `i`-th face of
`I₀`, then `fun J ↦ f (J.upper i) (J.face i) - f (J.lower i) (J.face i)` is box-additive on subboxes
of `I₀`. -/
@[simps!]
def upperSubLower.{u} {G : Type u} [AddCommGroup G] (I₀ : Box (Fin (n + 1))) (i : Fin (n + 1))
    (f : ℝ → Box (Fin n) → G) (fb : Icc (I₀.lower i) (I₀.upper i) → Fin n →ᵇᵃ[I₀.face i] G)
    (hf : ∀ (x) (hx : x ∈ Icc (I₀.lower i) (I₀.upper i)) (J), f x J = fb ⟨x, hx⟩ J) :
    Fin (n + 1) →ᵇᵃ[I₀] G :=
  ofMapSplitAdd (fun J : Box (Fin (n + 1)) => f (J.upper i) (J.face i) - f (J.lower i) (J.face i))
    I₀
    (by
      intro J hJ j x
      rw [WithTop.coe_le_coe] at hJ
      refine' i.succAboveCases (fun hx => _) (fun j hx => _) j
      · simp only [Box.splitLower_def hx, Box.splitUpper_def hx, update_same, ← WithBot.some_eq_coe,
          Option.elim', Box.face, (· ∘ ·), update_noteq (Fin.succAbove_ne _ _)]
        abel
      · have : (J.face i : WithTop (Box (Fin n))) ≤ I₀.face i :=
          WithTop.coe_le_coe.2 (face_mono hJ i)
        rw [le_iff_Icc, @Box.Icc_eq_pi _ I₀] at hJ
        simp only
        rw [hf _ (hJ J.upper_mem_Icc _ trivial), hf _ (hJ J.lower_mem_Icc _ trivial),
          ← (fb _).map_split_add this j x, ← (fb _).map_split_add this j x]
        have hx' : x ∈ Ioo ((J.face i).lower j) ((J.face i).upper j) := hx
        

Proof state:
case refine'_2
ι : Type u_1
M : Type u_2
n : ℕ
N : Type u_3
inst✝² : AddCommMonoid M
inst✝¹ : AddCommMonoid N
I₀✝ : WithTop (Box ι)
I J✝ : Box ι
i✝ : ι
G : Type u
inst✝ : AddCommGroup G
I₀ : Box (Fin (n + 1))
i : Fin (n + 1)
f : ℝ → Box (Fin n) → G
fb : ↑(Set.Icc (lower I₀ i) (upper I₀ i)) → Fin n →ᵇᵃ[↑(face I₀ i)] G
hf :
  ∀ (x : ℝ) (hx : x ∈ Set.Icc (lower I₀ i) (upper I₀ i)) (J : Box (Fin n)), f x J = (fb { val := x, property := hx }) J
J : Box (Fin (n + 1))
hJ : Box.Icc J ⊆ Set.pi Set.univ fun i => Set.Icc (lower I₀ i) (upper I₀ i)
j✝ : Fin (n + 1)
x : ℝ
j : Fin n
hx : x ∈ Set.Ioo (lower J (Fin.succAbove i j)) (upper J (Fin.succAbove i j))
this : ↑(face J i) ≤ ↑(face I₀ i)
hx' : x ∈ Set.Ioo (lower (face J i) j) (upper (face J i) j)
⊢ Option.elim' 0 (fun J => f (upper J i) (face J i) - f (lower J i) (face J i)) (splitLower J (Fin.succAbove i j) x) +
      Option.elim' 0 (fun J => f (upper J i) (face J i) - f (lower J i) (face J i))
        (splitUpper J (Fin.succAbove i j) x) =
    Option.elim' 0
          (⇑(fb { val := upper J i, property := (_ : upper J i ∈ (fun i => Set.Icc (lower I₀ i) (upper I₀ i)) i) }))
          (splitLower (face J i) j x) +
        Option.elim' 0
          (⇑(fb { val := upper J i, property := (_ : upper J i ∈ (fun i => Set.Icc (lower I₀ i) (upper I₀ i)) i) }))
          (splitUpper (face J i) j x) -
      (Option.elim' 0
          (⇑(fb { val := lower J i, property := (_ : lower J i ∈ (fun i => Set.Icc (lower I₀ i) (upper I₀ i)) i) }))
          (splitLower (face J i) j x) +
        Option.elim' 0
          (⇑(fb { val := lower J i, property := (_ : lower J i ∈ (fun i => Set.Icc (lower I₀ i) (upper I₀ i)) i) }))
          (splitUpper (face J i) j x))

Next tactic:
simp only [Box.splitLower_def hx, Box.splitUpper_def hx, Box.splitLower_def hx',
          Box.splitUpper_def hx', ← WithBot.some_eq_coe, Option.elim', Box.face_mk,
          update_noteq (Fin.succAbove_ne _ _).symm, sub_add_sub_comm,
          update_comp_eq_of_injective _ (Fin.strictMono_succAbove i).injective j x, ← hf]