l3lab/ntp-mathlib huggingface dataset:
@[to_additive]
theorem noncommProd_mul_single [Fintype ι] [DecidableEq ι] (x : ∀ i, M i) :
    (univ.noncommProd (fun i => Pi.mulSingle i (x i)) fun i _ j _ _ =>
        Pi.mulSingle_apply_commute x i j) = x := by
  ext i
  apply (univ.noncommProd_map (fun i => MonoidHom.single M i (x i)) ?a (Pi.evalMonoidHom M i)).trans
  case a =>
    intro i _ j _ _
    exact Pi.mulSingle_apply_commute x i j
  refine' (noncommProd_congr (insert_erase (mem_univ i)).symm _ _).trans _
  · intro j
    exact Pi.mulSingle j (x j) i
  · intro j _; dsimp
  · rw [noncommProd_insert_of_not_mem _ _ _ _ (not_mem_erase _ _),
      noncommProd_eq_pow_card (univ.erase i), one_pow, mul_one]
    simp only [MonoidHom.single_apply, ne_eq, Pi.mulSingle_eq_same]
    · intro j hj
      simp? at hj says simp only [mem_univ, not_true_eq_false, mem_erase, ne_eq, and_true] at hj
      simp only [MonoidHom.single_apply, Pi.mulSingle, Function.update, Eq.ndrec, Pi.one_apply,
        ne_eq, dite_eq_right_iff]
      intro h
      

Proof state:
case h.refine'_3.h
F : Type u_1
ι : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f : α → β → β
op : α → α → α
inst✝⁴ : Monoid β
inst✝³ : Monoid γ
M : ι → Type u_6
inst✝² : (i : ι) → Monoid (M i)
inst✝¹ : Fintype ι
inst✝ : DecidableEq ι
x : (i : ι) → M i
i j : ι
hj : ¬j = i
h : i = j
⊢ (_ : j = i) ▸ x j = 1

Next tactic:
simp [*] at *
@[to_additive]
theorem _root_.MonoidHom.pi_ext [Finite ι] [DecidableEq ι] {f g : (∀ i, M i) →* γ}
    (h : ∀ i x, f (Pi.mulSingle i x) = g (Pi.mulSingle i x)) : f = g := by
  

Proof state:
F : Type u_1
ι : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f✝ : α → β → β
op : α → α → α
inst✝⁴ : Monoid β
inst✝³ : Monoid γ
M : ι → Type u_6
inst✝² : (i : ι) → Monoid (M i)
inst✝¹ : Finite ι
inst✝ : DecidableEq ι
f g : ((i : ι) → M i) →* γ
h : ∀ (i : ι) (x : M i), f (Pi.mulSingle i x) = g (Pi.mulSingle i x)
⊢ f = g

Next tactic:
cases nonempty_fintype ι
@[to_additive]
theorem _root_.MonoidHom.pi_ext [Finite ι] [DecidableEq ι] {f g : (∀ i, M i) →* γ}
    (h : ∀ i x, f (Pi.mulSingle i x) = g (Pi.mulSingle i x)) : f = g := by
  cases nonempty_fintype ι
  

Proof state:
case intro
F : Type u_1
ι : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f✝ : α → β → β
op : α → α → α
inst✝⁴ : Monoid β
inst✝³ : Monoid γ
M : ι → Type u_6
inst✝² : (i : ι) → Monoid (M i)
inst✝¹ : Finite ι
inst✝ : DecidableEq ι
f g : ((i : ι) → M i) →* γ
h : ∀ (i : ι) (x : M i), f (Pi.mulSingle i x) = g (Pi.mulSingle i x)
val✝ : Fintype ι
⊢ f = g

Next tactic:
ext x
@[to_additive]
theorem _root_.MonoidHom.pi_ext [Finite ι] [DecidableEq ι] {f g : (∀ i, M i) →* γ}
    (h : ∀ i x, f (Pi.mulSingle i x) = g (Pi.mulSingle i x)) : f = g := by
  cases nonempty_fintype ι
  ext x
  

Proof state:
case intro.h
F : Type u_1
ι : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f✝ : α → β → β
op : α → α → α
inst✝⁴ : Monoid β
inst✝³ : Monoid γ
M : ι → Type u_6
inst✝² : (i : ι) → Monoid (M i)
inst✝¹ : Finite ι
inst✝ : DecidableEq ι
f g : ((i : ι) → M i) →* γ
h : ∀ (i : ι) (x : M i), f (Pi.mulSingle i x) = g (Pi.mulSingle i x)
val✝ : Fintype ι
x : (i : ι) → M i
⊢ f x = g x

Next tactic:
rw [← noncommProd_mul_single x, univ.noncommProd_map, univ.noncommProd_map]
@[to_additive]
theorem _root_.MonoidHom.pi_ext [Finite ι] [DecidableEq ι] {f g : (∀ i, M i) →* γ}
    (h : ∀ i x, f (Pi.mulSingle i x) = g (Pi.mulSingle i x)) : f = g := by
  cases nonempty_fintype ι
  ext x
  rw [← noncommProd_mul_single x, univ.noncommProd_map, univ.noncommProd_map]
  

Proof state:
case intro.h
F : Type u_1
ι : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f✝ : α → β → β
op : α → α → α
inst✝⁴ : Monoid β
inst✝³ : Monoid γ
M : ι → Type u_6
inst✝² : (i : ι) → Monoid (M i)
inst✝¹ : Finite ι
inst✝ : DecidableEq ι
f g : ((i : ι) → M i) →* γ
h : ∀ (i : ι) (x : M i), f (Pi.mulSingle i x) = g (Pi.mulSingle i x)
val✝ : Fintype ι
x : (i : ι) → M i
⊢ noncommProd univ (fun i => f (Pi.mulSingle i (x i)))
      (_ : ∀ x_1 ∈ ↑univ, ∀ y ∈ ↑univ, x_1 ≠ y → Commute (f (Pi.mulSingle x_1 (x x_1))) (f (Pi.mulSingle y (x y)))) =
    noncommProd univ (fun i => g (Pi.mulSingle i (x i)))
      (_ : ∀ x_1 ∈ ↑univ, ∀ y ∈ ↑univ, x_1 ≠ y → Commute (g (Pi.mulSingle x_1 (x x_1))) (g (Pi.mulSingle y (x y))))

Next tactic:
congr 1 with i
@[to_additive]
theorem _root_.MonoidHom.pi_ext [Finite ι] [DecidableEq ι] {f g : (∀ i, M i) →* γ}
    (h : ∀ i x, f (Pi.mulSingle i x) = g (Pi.mulSingle i x)) : f = g := by
  cases nonempty_fintype ι
  ext x
  rw [← noncommProd_mul_single x, univ.noncommProd_map, univ.noncommProd_map]
  congr 1 with i; 

Proof state:
case intro.h.e_f.h
F : Type u_1
ι : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f✝ : α → β → β
op : α → α → α
inst✝⁴ : Monoid β
inst✝³ : Monoid γ
M : ι → Type u_6
inst✝² : (i : ι) → Monoid (M i)
inst✝¹ : Finite ι
inst✝ : DecidableEq ι
f g : ((i : ι) → M i) →* γ
h : ∀ (i : ι) (x : M i), f (Pi.mulSingle i x) = g (Pi.mulSingle i x)
val✝ : Fintype ι
x : (i : ι) → M i
i : ι
⊢ f (Pi.mulSingle i (x i)) = g (Pi.mulSingle i (x i))

Next tactic:
exact h i (x i)
/-- Split a box in `ℝⁿ` into `2 ^ n` boxes by hyperplanes passing through its center. -/
def splitCenter (I : Box ι) : Prepartition I where
  boxes := Finset.univ.map (Box.splitCenterBoxEmb I)
  le_of_mem' := by 

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J I : Box ι
⊢ ∀ J ∈ Finset.map (Box.splitCenterBoxEmb I) Finset.univ, J ≤ I

Next tactic:
simp [I.splitCenterBox_le]
/-- Split a box in `ℝⁿ` into `2 ^ n` boxes by hyperplanes passing through its center. -/
def splitCenter (I : Box ι) : Prepartition I where
  boxes := Finset.univ.map (Box.splitCenterBoxEmb I)
  le_of_mem' := by simp [I.splitCenterBox_le]
  pairwiseDisjoint := by
    

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J I : Box ι
⊢ Set.Pairwise (↑(Finset.map (Box.splitCenterBoxEmb I) Finset.univ)) (Disjoint on Box.toSet)

Next tactic:
rw [Finset.coe_map, Finset.coe_univ, image_univ]
/-- Split a box in `ℝⁿ` into `2 ^ n` boxes by hyperplanes passing through its center. -/
def splitCenter (I : Box ι) : Prepartition I where
  boxes := Finset.univ.map (Box.splitCenterBoxEmb I)
  le_of_mem' := by simp [I.splitCenterBox_le]
  pairwiseDisjoint := by
    rw [Finset.coe_map, Finset.coe_univ, image_univ]
    

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J I : Box ι
⊢ Set.Pairwise (range ⇑(Box.splitCenterBoxEmb I)) (Disjoint on Box.toSet)

Next tactic:
rintro _ ⟨s, rfl⟩ _ ⟨t, rfl⟩ Hne
/-- Split a box in `ℝⁿ` into `2 ^ n` boxes by hyperplanes passing through its center. -/
def splitCenter (I : Box ι) : Prepartition I where
  boxes := Finset.univ.map (Box.splitCenterBoxEmb I)
  le_of_mem' := by simp [I.splitCenterBox_le]
  pairwiseDisjoint := by
    rw [Finset.coe_map, Finset.coe_univ, image_univ]
    rintro _ ⟨s, rfl⟩ _ ⟨t, rfl⟩ Hne
    

Proof state:
case intro.intro
ι : Type u_1
inst✝ : Fintype ι
I✝ J I : Box ι
s t : Set ι
Hne : (Box.splitCenterBoxEmb I) s ≠ (Box.splitCenterBoxEmb I) t
⊢ (Disjoint on Box.toSet) ((Box.splitCenterBoxEmb I) s) ((Box.splitCenterBoxEmb I) t)

Next tactic:
exact I.disjoint_splitCenterBox (mt (congr_arg _) Hne)
@[simp]
theorem mem_splitCenter : J ∈ splitCenter I ↔ ∃ s, I.splitCenterBox s = J := by 

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
⊢ J ∈ splitCenter I ↔ ∃ s, Box.splitCenterBox I s = J

Next tactic:
simp [splitCenter]
theorem isPartition_splitCenter (I : Box ι) : IsPartition (splitCenter I) := fun x hx => by
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J I : Box ι
x : ι → ℝ
hx : x ∈ I
⊢ ∃ J ∈ splitCenter I, x ∈ J

Next tactic:
simp [hx]
/-- Let `p` be a predicate on `Box ι`, let `I` be a box. Suppose that the following two properties
hold true.

* Consider a smaller box `J ≤ I`. The hyperplanes passing through the center of `J` split it into
  `2 ^ n` boxes. If `p` holds true on each of these boxes, then it true on `J`.
* For each `z` in the closed box `I.Icc` there exists a neighborhood `U` of `z` within `I.Icc` such
  that for every box `J ≤ I` such that `z ∈ J.Icc ⊆ U`, if `J` is homothetic to `I` with a
  coefficient of the form `1 / 2 ^ m`, then `p` is true on `J`.

Then `p I` is true. See also `BoxIntegral.Box.subbox_induction_on'` for a version using
`BoxIntegral.Box.splitCenterBox` instead of `BoxIntegral.Prepartition.splitCenter`. -/
@[elab_as_elim]
theorem subbox_induction_on {p : Box ι → Prop} (I : Box ι)
    (H_ind : ∀ J ≤ I, (∀ J' ∈ splitCenter J, p J') → p J)
    (H_nhds : ∀ z ∈ Box.Icc I, ∃ U ∈ 𝓝[Box.Icc I] z, ∀ J ≤ I, ∀ (m : ℕ),
      z ∈ Box.Icc J → Box.Icc J ⊆ U →
        (∀ i, J.upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) → p J) :
    p I := by
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J : Box ι
p : Box ι → Prop
I : Box ι
H_ind : ∀ J ≤ I, (∀ J' ∈ splitCenter J, p J') → p J
H_nhds :
  ∀ z ∈ Box.Icc I,
    ∃ U ∈ 𝓝[Box.Icc I] z,
      ∀ J ≤ I,
        ∀ (m : ℕ),
          z ∈ Box.Icc J → Box.Icc J ⊆ U → (∀ (i : ι), upper J i - lower J i = (upper I i - lower I i) / 2 ^ m) → p J
⊢ p I

Next tactic:
refine' subbox_induction_on' I (fun J hle hs => H_ind J hle fun J' h' => _) H_nhds
/-- Let `p` be a predicate on `Box ι`, let `I` be a box. Suppose that the following two properties
hold true.

* Consider a smaller box `J ≤ I`. The hyperplanes passing through the center of `J` split it into
  `2 ^ n` boxes. If `p` holds true on each of these boxes, then it true on `J`.
* For each `z` in the closed box `I.Icc` there exists a neighborhood `U` of `z` within `I.Icc` such
  that for every box `J ≤ I` such that `z ∈ J.Icc ⊆ U`, if `J` is homothetic to `I` with a
  coefficient of the form `1 / 2 ^ m`, then `p` is true on `J`.

Then `p I` is true. See also `BoxIntegral.Box.subbox_induction_on'` for a version using
`BoxIntegral.Box.splitCenterBox` instead of `BoxIntegral.Prepartition.splitCenter`. -/
@[elab_as_elim]
theorem subbox_induction_on {p : Box ι → Prop} (I : Box ι)
    (H_ind : ∀ J ≤ I, (∀ J' ∈ splitCenter J, p J') → p J)
    (H_nhds : ∀ z ∈ Box.Icc I, ∃ U ∈ 𝓝[Box.Icc I] z, ∀ J ≤ I, ∀ (m : ℕ),
      z ∈ Box.Icc J → Box.Icc J ⊆ U →
        (∀ i, J.upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) → p J) :
    p I := by
  refine' subbox_induction_on' I (fun J hle hs => H_ind J hle fun J' h' => _) H_nhds
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J✝ : Box ι
p : Box ι → Prop
I : Box ι
H_ind : ∀ J ≤ I, (∀ J' ∈ splitCenter J, p J') → p J
H_nhds :
  ∀ z ∈ Box.Icc I,
    ∃ U ∈ 𝓝[Box.Icc I] z,
      ∀ J ≤ I,
        ∀ (m : ℕ),
          z ∈ Box.Icc J → Box.Icc J ⊆ U → (∀ (i : ι), upper J i - lower J i = (upper I i - lower I i) / 2 ^ m) → p J
J : Box ι
hle : J ≤ I
hs : ∀ (s : Set ι), p (splitCenterBox J s)
J' : Box ι
h' : J' ∈ splitCenter J
⊢ p J'

Next tactic:
rcases mem_splitCenter.1 h' with ⟨s, rfl⟩
/-- Let `p` be a predicate on `Box ι`, let `I` be a box. Suppose that the following two properties
hold true.

* Consider a smaller box `J ≤ I`. The hyperplanes passing through the center of `J` split it into
  `2 ^ n` boxes. If `p` holds true on each of these boxes, then it true on `J`.
* For each `z` in the closed box `I.Icc` there exists a neighborhood `U` of `z` within `I.Icc` such
  that for every box `J ≤ I` such that `z ∈ J.Icc ⊆ U`, if `J` is homothetic to `I` with a
  coefficient of the form `1 / 2 ^ m`, then `p` is true on `J`.

Then `p I` is true. See also `BoxIntegral.Box.subbox_induction_on'` for a version using
`BoxIntegral.Box.splitCenterBox` instead of `BoxIntegral.Prepartition.splitCenter`. -/
@[elab_as_elim]
theorem subbox_induction_on {p : Box ι → Prop} (I : Box ι)
    (H_ind : ∀ J ≤ I, (∀ J' ∈ splitCenter J, p J') → p J)
    (H_nhds : ∀ z ∈ Box.Icc I, ∃ U ∈ 𝓝[Box.Icc I] z, ∀ J ≤ I, ∀ (m : ℕ),
      z ∈ Box.Icc J → Box.Icc J ⊆ U →
        (∀ i, J.upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) → p J) :
    p I := by
  refine' subbox_induction_on' I (fun J hle hs => H_ind J hle fun J' h' => _) H_nhds
  rcases mem_splitCenter.1 h' with ⟨s, rfl⟩
  

Proof state:
case intro
ι : Type u_1
inst✝ : Fintype ι
I✝ J✝ : Box ι
p : Box ι → Prop
I : Box ι
H_ind : ∀ J ≤ I, (∀ J' ∈ splitCenter J, p J') → p J
H_nhds :
  ∀ z ∈ Box.Icc I,
    ∃ U ∈ 𝓝[Box.Icc I] z,
      ∀ J ≤ I,
        ∀ (m : ℕ),
          z ∈ Box.Icc J → Box.Icc J ⊆ U → (∀ (i : ι), upper J i - lower J i = (upper I i - lower I i) / 2 ^ m) → p J
J : Box ι
hle : J ≤ I
hs : ∀ (s : Set ι), p (splitCenterBox J s)
s : Set ι
h' : splitCenterBox J s ∈ splitCenter J
⊢ p (splitCenterBox J s)

Next tactic:
exact hs s
/-- Given a box `I` in `ℝⁿ` and a function `r : ℝⁿ → (0, ∞)`, there exists a tagged partition `π` of
`I` such that

* `π` is a Henstock partition;
* `π` is subordinate to `r`;
* each box in `π` is homothetic to `I` with coefficient of the form `1 / 2 ^ m`.

This lemma implies that the Henstock filter is nontrivial, hence the Henstock integral is
well-defined. -/
theorem exists_taggedPartition_isHenstock_isSubordinate_homothetic (I : Box ι)
    (r : (ι → ℝ) → Ioi (0 : ℝ)) :
    ∃ π : TaggedPrepartition I, π.IsPartition ∧ π.IsHenstock ∧ π.IsSubordinate r ∧
      (∀ J ∈ π, ∃ m : ℕ, ∀ i, (J : _).upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) ∧
        π.distortion = I.distortion := by
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J I : Box ι
r : (ι → ℝ) → ↑(Ioi 0)
⊢ ∃ π,
    TaggedPrepartition.IsPartition π ∧
      IsHenstock π ∧
        IsSubordinate π r ∧
          (∀ J ∈ π, ∃ m, ∀ (i : ι), upper J i - lower J i = (upper I i - lower I i) / 2 ^ m) ∧
            TaggedPrepartition.distortion π = distortion I

Next tactic:
refine' subbox_induction_on I (fun J _ hJ => _) fun z _ => _
/-- Given a box `I` in `ℝⁿ` and a function `r : ℝⁿ → (0, ∞)`, there exists a tagged partition `π` of
`I` such that

* `π` is a Henstock partition;
* `π` is subordinate to `r`;
* each box in `π` is homothetic to `I` with coefficient of the form `1 / 2 ^ m`.

This lemma implies that the Henstock filter is nontrivial, hence the Henstock integral is
well-defined. -/
theorem exists_taggedPartition_isHenstock_isSubordinate_homothetic (I : Box ι)
    (r : (ι → ℝ) → Ioi (0 : ℝ)) :
    ∃ π : TaggedPrepartition I, π.IsPartition ∧ π.IsHenstock ∧ π.IsSubordinate r ∧
      (∀ J ∈ π, ∃ m : ℕ, ∀ i, (J : _).upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) ∧
        π.distortion = I.distortion := by
  refine' subbox_induction_on I (fun J _ hJ => _) fun z _ => _
  · 

Proof state:
case refine'_1
ι : Type u_1
inst✝ : Fintype ι
I✝ J✝ I : Box ι
r : (ι → ℝ) → ↑(Ioi 0)
J : Box ι
x✝ : J ≤ I
hJ :
  ∀ J' ∈ splitCenter J,
    ∃ π,
      TaggedPrepartition.IsPartition π ∧
        IsHenstock π ∧
          IsSubordinate π r ∧
            (∀ J ∈ π, ∃ m, ∀ (i : ι), upper J i - lower J i = (upper J' i - lower J' i) / 2 ^ m) ∧
              TaggedPrepartition.distortion π = distortion J'
⊢ ∃ π,
    TaggedPrepartition.IsPartition π ∧
      IsHenstock π ∧
        IsSubordinate π r ∧
          (∀ J_1 ∈ π, ∃ m, ∀ (i : ι), upper J_1 i - lower J_1 i = (upper J i - lower J i) / 2 ^ m) ∧
            TaggedPrepartition.distortion π = distortion J

Next tactic:
choose! πi hP hHen hr Hn _ using hJ
/-- Given a box `I` in `ℝⁿ` and a function `r : ℝⁿ → (0, ∞)`, there exists a tagged partition `π` of
`I` such that

* `π` is a Henstock partition;
* `π` is subordinate to `r`;
* each box in `π` is homothetic to `I` with coefficient of the form `1 / 2 ^ m`.

This lemma implies that the Henstock filter is nontrivial, hence the Henstock integral is
well-defined. -/
theorem exists_taggedPartition_isHenstock_isSubordinate_homothetic (I : Box ι)
    (r : (ι → ℝ) → Ioi (0 : ℝ)) :
    ∃ π : TaggedPrepartition I, π.IsPartition ∧ π.IsHenstock ∧ π.IsSubordinate r ∧
      (∀ J ∈ π, ∃ m : ℕ, ∀ i, (J : _).upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) ∧
        π.distortion = I.distortion := by
  refine' subbox_induction_on I (fun J _ hJ => _) fun z _ => _
  · choose! πi hP hHen hr Hn _ using hJ
    

Proof state:
case refine'_1
ι : Type u_1
inst✝ : Fintype ι
I✝ J✝ I : Box ι
r : (ι → ℝ) → ↑(Ioi 0)
J : Box ι
x✝ : J ≤ I
πi : (J' : Box ι) → TaggedPrepartition J'
hP : ∀ J' ∈ splitCenter J, TaggedPrepartition.IsPartition (πi J')
hHen : ∀ J' ∈ splitCenter J, IsHenstock (πi J')
hr : ∀ J' ∈ splitCenter J, IsSubordinate (πi J') r
Hn : ∀ J' ∈ splitCenter J, ∀ J ∈ πi J', ∃ m, ∀ (i : ι), upper J i - lower J i = (upper J' i - lower J' i) / 2 ^ m
✝ : ∀ J' ∈ splitCenter J, TaggedPrepartition.distortion (πi J') = distortion J'
⊢ ∃ π,
    TaggedPrepartition.IsPartition π ∧
      IsHenstock π ∧
        IsSubordinate π r ∧
          (∀ J_1 ∈ π, ∃ m, ∀ (i : ι), upper J_1 i - lower J_1 i = (upper J i - lower J i) / 2 ^ m) ∧
            TaggedPrepartition.distortion π = distortion J

Next tactic:
choose! n hn using Hn
/-- Given a box `I` in `ℝⁿ` and a function `r : ℝⁿ → (0, ∞)`, there exists a tagged partition `π` of
`I` such that

* `π` is a Henstock partition;
* `π` is subordinate to `r`;
* each box in `π` is homothetic to `I` with coefficient of the form `1 / 2 ^ m`.

This lemma implies that the Henstock filter is nontrivial, hence the Henstock integral is
well-defined. -/
theorem exists_taggedPartition_isHenstock_isSubordinate_homothetic (I : Box ι)
    (r : (ι → ℝ) → Ioi (0 : ℝ)) :
    ∃ π : TaggedPrepartition I, π.IsPartition ∧ π.IsHenstock ∧ π.IsSubordinate r ∧
      (∀ J ∈ π, ∃ m : ℕ, ∀ i, (J : _).upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) ∧
        π.distortion = I.distortion := by
  refine' subbox_induction_on I (fun J _ hJ => _) fun z _ => _
  · choose! πi hP hHen hr Hn _ using hJ
    choose! n hn using Hn
    

Proof state:
case refine'_1
ι : Type u_1
inst✝ : Fintype ι
I✝ J✝ I : Box ι
r : (ι → ℝ) → ↑(Ioi 0)
J : Box ι
x✝ : J ≤ I
πi : (J' : Box ι) → TaggedPrepartition J'
hP : ∀ J' ∈ splitCenter J, TaggedPrepartition.IsPartition (πi J')
hHen : ∀ J' ∈ splitCenter J, IsHenstock (πi J')
hr : ∀ J' ∈ splitCenter J, IsSubordinate (πi J') r
✝ : ∀ J' ∈ splitCenter J, TaggedPrepartition.distortion (πi J') = distortion J'
n : Box ι → Box ι → ℕ
hn : ∀ J' ∈ splitCenter J, ∀ J ∈ πi J', ∀ (i : ι), upper J i - lower J i = (upper J' i - lower J' i) / 2 ^ n J' J
⊢ ∃ π,
    TaggedPrepartition.IsPartition π ∧
      IsHenstock π ∧
        IsSubordinate π r ∧
          (∀ J_1 ∈ π, ∃ m, ∀ (i : ι), upper J_1 i - lower J_1 i = (upper J i - lower J i) / 2 ^ m) ∧
            TaggedPrepartition.distortion π = distortion J

Next tactic:
have hP : ((splitCenter J).biUnionTagged πi).IsPartition :=
      (isPartition_splitCenter _).biUnionTagged hP
/-- Given a box `I` in `ℝⁿ` and a function `r : ℝⁿ → (0, ∞)`, there exists a tagged partition `π` of
`I` such that

* `π` is a Henstock partition;
* `π` is subordinate to `r`;
* each box in `π` is homothetic to `I` with coefficient of the form `1 / 2 ^ m`.

This lemma implies that the Henstock filter is nontrivial, hence the Henstock integral is
well-defined. -/
theorem exists_taggedPartition_isHenstock_isSubordinate_homothetic (I : Box ι)
    (r : (ι → ℝ) → Ioi (0 : ℝ)) :
    ∃ π : TaggedPrepartition I, π.IsPartition ∧ π.IsHenstock ∧ π.IsSubordinate r ∧
      (∀ J ∈ π, ∃ m : ℕ, ∀ i, (J : _).upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) ∧
        π.distortion = I.distortion := by
  refine' subbox_induction_on I (fun J _ hJ => _) fun z _ => _
  · choose! πi hP hHen hr Hn _ using hJ
    choose! n hn using Hn
    have hP : ((splitCenter J).biUnionTagged πi).IsPartition :=
      (isPartition_splitCenter _).biUnionTagged hP
    

Proof state:
case refine'_1
ι : Type u_1
inst✝ : Fintype ι
I✝ J✝ I : Box ι
r : (ι → ℝ) → ↑(Ioi 0)
J : Box ι
x✝ : J ≤ I
πi : (J' : Box ι) → TaggedPrepartition J'
hP✝ : ∀ J' ∈ splitCenter J, TaggedPrepartition.IsPartition (πi J')
hHen : ∀ J' ∈ splitCenter J, IsHenstock (πi J')
hr : ∀ J' ∈ splitCenter J, IsSubordinate (πi J') r
✝ : ∀ J' ∈ splitCenter J, TaggedPrepartition.distortion (πi J') = distortion J'
n : Box ι → Box ι → ℕ
hn : ∀ J' ∈ splitCenter J, ∀ J ∈ πi J', ∀ (i : ι), upper J i - lower J i = (upper J' i - lower J' i) / 2 ^ n J' J
hP : TaggedPrepartition.IsPartition (biUnionTagged (splitCenter J) πi)
⊢ ∃ π,
    TaggedPrepartition.IsPartition π ∧
      IsHenstock π ∧
        IsSubordinate π r ∧
          (∀ J_1 ∈ π, ∃ m, ∀ (i : ι), upper J_1 i - lower J_1 i = (upper J i - lower J i) / 2 ^ m) ∧
            TaggedPrepartition.distortion π = distortion J

Next tactic:
have hsub : ∀ J' ∈ (splitCenter J).biUnionTagged πi, ∃ n : ℕ, ∀ i,
        (J' : _).upper i - J'.lower i = (J.upper i - J.lower i) / 2 ^ n := by
      intro J' hJ'
      rcases (splitCenter J).mem_biUnionTagged.1 hJ' with ⟨J₁, h₁, h₂⟩
      refine' ⟨n J₁ J' + 1, fun i => _⟩
      simp only [hn J₁ h₁ J' h₂, upper_sub_lower_of_mem_splitCenter h₁, pow_succ, div_div]
/-- Given a box `I` in `ℝⁿ` and a function `r : ℝⁿ → (0, ∞)`, there exists a tagged partition `π` of
`I` such that

* `π` is a Henstock partition;
* `π` is subordinate to `r`;
* each box in `π` is homothetic to `I` with coefficient of the form `1 / 2 ^ m`.

This lemma implies that the Henstock filter is nontrivial, hence the Henstock integral is
well-defined. -/
theorem exists_taggedPartition_isHenstock_isSubordinate_homothetic (I : Box ι)
    (r : (ι → ℝ) → Ioi (0 : ℝ)) :
    ∃ π : TaggedPrepartition I, π.IsPartition ∧ π.IsHenstock ∧ π.IsSubordinate r ∧
      (∀ J ∈ π, ∃ m : ℕ, ∀ i, (J : _).upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) ∧
        π.distortion = I.distortion := by
  refine' subbox_induction_on I (fun J _ hJ => _) fun z _ => _
  · choose! πi hP hHen hr Hn _ using hJ
    choose! n hn using Hn
    have hP : ((splitCenter J).biUnionTagged πi).IsPartition :=
      (isPartition_splitCenter _).biUnionTagged hP
    have hsub : ∀ J' ∈ (splitCenter J).biUnionTagged πi, ∃ n : ℕ, ∀ i,
        (J' : _).upper i - J'.lower i = (J.upper i - J.lower i) / 2 ^ n := by
      

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J✝ I : Box ι
r : (ι → ℝ) → ↑(Ioi 0)
J : Box ι
x✝ : J ≤ I
πi : (J' : Box ι) → TaggedPrepartition J'
hP✝ : ∀ J' ∈ splitCenter J, TaggedPrepartition.IsPartition (πi J')
hHen : ∀ J' ∈ splitCenter J, IsHenstock (πi J')
hr : ∀ J' ∈ splitCenter J, IsSubordinate (πi J') r
✝ : ∀ J' ∈ splitCenter J, TaggedPrepartition.distortion (πi J') = distortion J'
n : Box ι → Box ι → ℕ
hn : ∀ J' ∈ splitCenter J, ∀ J ∈ πi J', ∀ (i : ι), upper J i - lower J i = (upper J' i - lower J' i) / 2 ^ n J' J
hP : TaggedPrepartition.IsPartition (biUnionTagged (splitCenter J) πi)
⊢ ∀ J' ∈ biUnionTagged (splitCenter J) πi, ∃ n, ∀ (i : ι), upper J' i - lower J' i = (upper J i - lower J i) / 2 ^ n

Next tactic:
intro J' hJ'
/-- Given a box `I` in `ℝⁿ` and a function `r : ℝⁿ → (0, ∞)`, there exists a tagged partition `π` of
`I` such that

* `π` is a Henstock partition;
* `π` is subordinate to `r`;
* each box in `π` is homothetic to `I` with coefficient of the form `1 / 2 ^ m`.

This lemma implies that the Henstock filter is nontrivial, hence the Henstock integral is
well-defined. -/
theorem exists_taggedPartition_isHenstock_isSubordinate_homothetic (I : Box ι)
    (r : (ι → ℝ) → Ioi (0 : ℝ)) :
    ∃ π : TaggedPrepartition I, π.IsPartition ∧ π.IsHenstock ∧ π.IsSubordinate r ∧
      (∀ J ∈ π, ∃ m : ℕ, ∀ i, (J : _).upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) ∧
        π.distortion = I.distortion := by
  refine' subbox_induction_on I (fun J _ hJ => _) fun z _ => _
  · choose! πi hP hHen hr Hn _ using hJ
    choose! n hn using Hn
    have hP : ((splitCenter J).biUnionTagged πi).IsPartition :=
      (isPartition_splitCenter _).biUnionTagged hP
    have hsub : ∀ J' ∈ (splitCenter J).biUnionTagged πi, ∃ n : ℕ, ∀ i,
        (J' : _).upper i - J'.lower i = (J.upper i - J.lower i) / 2 ^ n := by
      intro J' hJ'
      

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J✝ I : Box ι
r : (ι → ℝ) → ↑(Ioi 0)
J : Box ι
x✝ : J ≤ I
πi : (J' : Box ι) → TaggedPrepartition J'
hP✝ : ∀ J' ∈ splitCenter J, TaggedPrepartition.IsPartition (πi J')
hHen : ∀ J' ∈ splitCenter J, IsHenstock (πi J')
hr : ∀ J' ∈ splitCenter J, IsSubordinate (πi J') r
✝ : ∀ J' ∈ splitCenter J, TaggedPrepartition.distortion (πi J') = distortion J'
n : Box ι → Box ι → ℕ
hn : ∀ J' ∈ splitCenter J, ∀ J ∈ πi J', ∀ (i : ι), upper J i - lower J i = (upper J' i - lower J' i) / 2 ^ n J' J
hP : TaggedPrepartition.IsPartition (biUnionTagged (splitCenter J) πi)
J' : Box ι
hJ' : J' ∈ biUnionTagged (splitCenter J) πi
⊢ ∃ n, ∀ (i : ι), upper J' i - lower J' i = (upper J i - lower J i) / 2 ^ n

Next tactic:
rcases (splitCenter J).mem_biUnionTagged.1 hJ' with ⟨J₁, h₁, h₂⟩