l3lab/ntp-mathlib huggingface dataset:
protected theorem MemBaseSet.filter (hπ : l.MemBaseSet I c r π) (p : Box ι → Prop) :
    l.MemBaseSet I c r (π.filter p) := by
  refine' ⟨fun J hJ => hπ.1 J (π.mem_filter.1 hJ).1, fun hH J hJ => hπ.2 hH J (π.mem_filter.1 hJ).1,
    fun hD => (distortion_filter_le _ _).trans (hπ.3 hD), fun hD => _⟩
  rcases hπ.4 hD with ⟨π₁, hπ₁U, hc⟩
  set π₂ := π.filter fun J => ¬p J
  have : Disjoint π₁.iUnion π₂.iUnion := by
    simpa [hπ₁U] using disjoint_sdiff_self_left.mono_right sdiff_le
  refine' ⟨π₁.disjUnion π₂.toPrepartition this, _, _⟩
  · suffices ↑I \ π.iUnion ∪ π.iUnion \ (π.filter p).iUnion = ↑I \ (π.filter p).iUnion by simp [*]
    have h : (π.filter p).iUnion ⊆ π.iUnion :=
      biUnion_subset_biUnion_left (Finset.filter_subset _ _)
    ext x
    fconstructor
    · rintro (⟨hxI, hxπ⟩ | ⟨hxπ, hxp⟩)
      exacts [⟨hxI, mt (@h x) hxπ⟩, ⟨π.iUnion_subset hxπ, hxp⟩]
    · rintro ⟨hxI, hxp⟩
      

Proof state:
case intro.intro.refine'_1.h.mpr.intro
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁✝ π₂✝ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
hπ : MemBaseSet l I c r π
p : Box ι → Prop
hD : l.bDistortion = true
π₁ : Prepartition I
hπ₁U : Prepartition.iUnion π₁ = ↑I \ TaggedPrepartition.iUnion π
hc : Prepartition.distortion π₁ ≤ c
π₂ : TaggedPrepartition I := TaggedPrepartition.filter π fun J => ¬p J
this : Disjoint (Prepartition.iUnion π₁) (TaggedPrepartition.iUnion π₂)
h : TaggedPrepartition.iUnion (TaggedPrepartition.filter π p) ⊆ TaggedPrepartition.iUnion π
x : ι → ℝ
hxI : x ∈ ↑I
hxp : x ∉ TaggedPrepartition.iUnion (TaggedPrepartition.filter π p)
⊢ x ∈
    ↑I \ TaggedPrepartition.iUnion π ∪
      TaggedPrepartition.iUnion π \ TaggedPrepartition.iUnion (TaggedPrepartition.filter π p)

Next tactic:
by_cases hxπ : x ∈ π.iUnion
protected theorem MemBaseSet.filter (hπ : l.MemBaseSet I c r π) (p : Box ι → Prop) :
    l.MemBaseSet I c r (π.filter p) := by
  refine' ⟨fun J hJ => hπ.1 J (π.mem_filter.1 hJ).1, fun hH J hJ => hπ.2 hH J (π.mem_filter.1 hJ).1,
    fun hD => (distortion_filter_le _ _).trans (hπ.3 hD), fun hD => _⟩
  rcases hπ.4 hD with ⟨π₁, hπ₁U, hc⟩
  set π₂ := π.filter fun J => ¬p J
  have : Disjoint π₁.iUnion π₂.iUnion := by
    simpa [hπ₁U] using disjoint_sdiff_self_left.mono_right sdiff_le
  refine' ⟨π₁.disjUnion π₂.toPrepartition this, _, _⟩
  · suffices ↑I \ π.iUnion ∪ π.iUnion \ (π.filter p).iUnion = ↑I \ (π.filter p).iUnion by simp [*]
    have h : (π.filter p).iUnion ⊆ π.iUnion :=
      biUnion_subset_biUnion_left (Finset.filter_subset _ _)
    ext x
    fconstructor
    · rintro (⟨hxI, hxπ⟩ | ⟨hxπ, hxp⟩)
      exacts [⟨hxI, mt (@h x) hxπ⟩, ⟨π.iUnion_subset hxπ, hxp⟩]
    · rintro ⟨hxI, hxp⟩
      by_cases hxπ : x ∈ π.iUnion
      

Proof state:
case pos
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁✝ π₂✝ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
hπ : MemBaseSet l I c r π
p : Box ι → Prop
hD : l.bDistortion = true
π₁ : Prepartition I
hπ₁U : Prepartition.iUnion π₁ = ↑I \ TaggedPrepartition.iUnion π
hc : Prepartition.distortion π₁ ≤ c
π₂ : TaggedPrepartition I := TaggedPrepartition.filter π fun J => ¬p J
this : Disjoint (Prepartition.iUnion π₁) (TaggedPrepartition.iUnion π₂)
h : TaggedPrepartition.iUnion (TaggedPrepartition.filter π p) ⊆ TaggedPrepartition.iUnion π
x : ι → ℝ
hxI : x ∈ ↑I
hxp : x ∉ TaggedPrepartition.iUnion (TaggedPrepartition.filter π p)
hxπ : x ∈ TaggedPrepartition.iUnion π
⊢ x ∈
    ↑I \ TaggedPrepartition.iUnion π ∪
      TaggedPrepartition.iUnion π \ TaggedPrepartition.iUnion (TaggedPrepartition.filter π p)
case neg
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁✝ π₂✝ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
hπ : MemBaseSet l I c r π
p : Box ι → Prop
hD : l.bDistortion = true
π₁ : Prepartition I
hπ₁U : Prepartition.iUnion π₁ = ↑I \ TaggedPrepartition.iUnion π
hc : Prepartition.distortion π₁ ≤ c
π₂ : TaggedPrepartition I := TaggedPrepartition.filter π fun J => ¬p J
this : Disjoint (Prepartition.iUnion π₁) (TaggedPrepartition.iUnion π₂)
h : TaggedPrepartition.iUnion (TaggedPrepartition.filter π p) ⊆ TaggedPrepartition.iUnion π
x : ι → ℝ
hxI : x ∈ ↑I
hxp : x ∉ TaggedPrepartition.iUnion (TaggedPrepartition.filter π p)
hxπ : x ∉ TaggedPrepartition.iUnion π
⊢ x ∈
    ↑I \ TaggedPrepartition.iUnion π ∪
      TaggedPrepartition.iUnion π \ TaggedPrepartition.iUnion (TaggedPrepartition.filter π p)

Next tactic:
exacts [Or.inr ⟨hxπ, hxp⟩, Or.inl ⟨hxI, hxπ⟩]
protected theorem MemBaseSet.filter (hπ : l.MemBaseSet I c r π) (p : Box ι → Prop) :
    l.MemBaseSet I c r (π.filter p) := by
  refine' ⟨fun J hJ => hπ.1 J (π.mem_filter.1 hJ).1, fun hH J hJ => hπ.2 hH J (π.mem_filter.1 hJ).1,
    fun hD => (distortion_filter_le _ _).trans (hπ.3 hD), fun hD => _⟩
  rcases hπ.4 hD with ⟨π₁, hπ₁U, hc⟩
  set π₂ := π.filter fun J => ¬p J
  have : Disjoint π₁.iUnion π₂.iUnion := by
    simpa [hπ₁U] using disjoint_sdiff_self_left.mono_right sdiff_le
  refine' ⟨π₁.disjUnion π₂.toPrepartition this, _, _⟩
  · suffices ↑I \ π.iUnion ∪ π.iUnion \ (π.filter p).iUnion = ↑I \ (π.filter p).iUnion by simp [*]
    have h : (π.filter p).iUnion ⊆ π.iUnion :=
      biUnion_subset_biUnion_left (Finset.filter_subset _ _)
    ext x
    fconstructor
    · rintro (⟨hxI, hxπ⟩ | ⟨hxπ, hxp⟩)
      exacts [⟨hxI, mt (@h x) hxπ⟩, ⟨π.iUnion_subset hxπ, hxp⟩]
    · rintro ⟨hxI, hxp⟩
      by_cases hxπ : x ∈ π.iUnion
      exacts [Or.inr ⟨hxπ, hxp⟩, Or.inl ⟨hxI, hxπ⟩]
  · 

Proof state:
case intro.intro.refine'_2
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁✝ π₂✝ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
hπ : MemBaseSet l I c r π
p : Box ι → Prop
hD : l.bDistortion = true
π₁ : Prepartition I
hπ₁U : Prepartition.iUnion π₁ = ↑I \ TaggedPrepartition.iUnion π
hc : Prepartition.distortion π₁ ≤ c
π₂ : TaggedPrepartition I := TaggedPrepartition.filter π fun J => ¬p J
this : Disjoint (Prepartition.iUnion π₁) (TaggedPrepartition.iUnion π₂)
⊢ Prepartition.distortion (Prepartition.disjUnion π₁ π₂.toPrepartition this) ≤ c

Next tactic:
have : (π.filter fun J => ¬p J).distortion ≤ c := (distortion_filter_le _ _).trans (hπ.3 hD)
protected theorem MemBaseSet.filter (hπ : l.MemBaseSet I c r π) (p : Box ι → Prop) :
    l.MemBaseSet I c r (π.filter p) := by
  refine' ⟨fun J hJ => hπ.1 J (π.mem_filter.1 hJ).1, fun hH J hJ => hπ.2 hH J (π.mem_filter.1 hJ).1,
    fun hD => (distortion_filter_le _ _).trans (hπ.3 hD), fun hD => _⟩
  rcases hπ.4 hD with ⟨π₁, hπ₁U, hc⟩
  set π₂ := π.filter fun J => ¬p J
  have : Disjoint π₁.iUnion π₂.iUnion := by
    simpa [hπ₁U] using disjoint_sdiff_self_left.mono_right sdiff_le
  refine' ⟨π₁.disjUnion π₂.toPrepartition this, _, _⟩
  · suffices ↑I \ π.iUnion ∪ π.iUnion \ (π.filter p).iUnion = ↑I \ (π.filter p).iUnion by simp [*]
    have h : (π.filter p).iUnion ⊆ π.iUnion :=
      biUnion_subset_biUnion_left (Finset.filter_subset _ _)
    ext x
    fconstructor
    · rintro (⟨hxI, hxπ⟩ | ⟨hxπ, hxp⟩)
      exacts [⟨hxI, mt (@h x) hxπ⟩, ⟨π.iUnion_subset hxπ, hxp⟩]
    · rintro ⟨hxI, hxp⟩
      by_cases hxπ : x ∈ π.iUnion
      exacts [Or.inr ⟨hxπ, hxp⟩, Or.inl ⟨hxI, hxπ⟩]
  · have : (π.filter fun J => ¬p J).distortion ≤ c := (distortion_filter_le _ _).trans (hπ.3 hD)
    

Proof state:
case intro.intro.refine'_2
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁✝ π₂✝ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
hπ : MemBaseSet l I c r π
p : Box ι → Prop
hD : l.bDistortion = true
π₁ : Prepartition I
hπ₁U : Prepartition.iUnion π₁ = ↑I \ TaggedPrepartition.iUnion π
hc : Prepartition.distortion π₁ ≤ c
π₂ : TaggedPrepartition I := TaggedPrepartition.filter π fun J => ¬p J
this✝ : Disjoint (Prepartition.iUnion π₁) (TaggedPrepartition.iUnion π₂)
this : distortion (TaggedPrepartition.filter π fun J => ¬p J) ≤ c
⊢ Prepartition.distortion (Prepartition.disjUnion π₁ π₂.toPrepartition this✝) ≤ c

Next tactic:
simpa [hc]
theorem biUnionTagged_memBaseSet {π : Prepartition I} {πi : ∀ J, TaggedPrepartition J}
    (h : ∀ J ∈ π, l.MemBaseSet J c r (πi J)) (hp : ∀ J ∈ π, (πi J).IsPartition)
    (hc : l.bDistortion → π.compl.distortion ≤ c) : l.MemBaseSet I c r (π.biUnionTagged πi) := by
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π✝ π₁ π₂ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
π : Prepartition I
πi : (J : Box ι) → TaggedPrepartition J
h : ∀ J ∈ π, MemBaseSet l J c r (πi J)
hp : ∀ J ∈ π, IsPartition (πi J)
hc : l.bDistortion = true → Prepartition.distortion (Prepartition.compl π) ≤ c
⊢ MemBaseSet l I c r (Prepartition.biUnionTagged π πi)

Next tactic:
refine' ⟨TaggedPrepartition.isSubordinate_biUnionTagged.2 fun J hJ => (h J hJ).1,
    fun hH => TaggedPrepartition.isHenstock_biUnionTagged.2 fun J hJ => (h J hJ).2 hH,
    fun hD => _, fun hD => _⟩
theorem biUnionTagged_memBaseSet {π : Prepartition I} {πi : ∀ J, TaggedPrepartition J}
    (h : ∀ J ∈ π, l.MemBaseSet J c r (πi J)) (hp : ∀ J ∈ π, (πi J).IsPartition)
    (hc : l.bDistortion → π.compl.distortion ≤ c) : l.MemBaseSet I c r (π.biUnionTagged πi) := by
  refine' ⟨TaggedPrepartition.isSubordinate_biUnionTagged.2 fun J hJ => (h J hJ).1,
    fun hH => TaggedPrepartition.isHenstock_biUnionTagged.2 fun J hJ => (h J hJ).2 hH,
    fun hD => _, fun hD => _⟩
  · 

Proof state:
case refine'_1
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π✝ π₁ π₂ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
π : Prepartition I
πi : (J : Box ι) → TaggedPrepartition J
h : ∀ J ∈ π, MemBaseSet l J c r (πi J)
hp : ∀ J ∈ π, IsPartition (πi J)
hc : l.bDistortion = true → Prepartition.distortion (Prepartition.compl π) ≤ c
hD : l.bDistortion = true
⊢ distortion (Prepartition.biUnionTagged π πi) ≤ c

Next tactic:
rw [Prepartition.distortion_biUnionTagged, Finset.sup_le_iff]
theorem biUnionTagged_memBaseSet {π : Prepartition I} {πi : ∀ J, TaggedPrepartition J}
    (h : ∀ J ∈ π, l.MemBaseSet J c r (πi J)) (hp : ∀ J ∈ π, (πi J).IsPartition)
    (hc : l.bDistortion → π.compl.distortion ≤ c) : l.MemBaseSet I c r (π.biUnionTagged πi) := by
  refine' ⟨TaggedPrepartition.isSubordinate_biUnionTagged.2 fun J hJ => (h J hJ).1,
    fun hH => TaggedPrepartition.isHenstock_biUnionTagged.2 fun J hJ => (h J hJ).2 hH,
    fun hD => _, fun hD => _⟩
  · rw [Prepartition.distortion_biUnionTagged, Finset.sup_le_iff]
    

Proof state:
case refine'_1
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π✝ π₁ π₂ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
π : Prepartition I
πi : (J : Box ι) → TaggedPrepartition J
h : ∀ J ∈ π, MemBaseSet l J c r (πi J)
hp : ∀ J ∈ π, IsPartition (πi J)
hc : l.bDistortion = true → Prepartition.distortion (Prepartition.compl π) ≤ c
hD : l.bDistortion = true
⊢ ∀ b ∈ π.boxes, distortion (πi b) ≤ c

Next tactic:
exact fun J hJ => (h J hJ).3 hD
theorem biUnionTagged_memBaseSet {π : Prepartition I} {πi : ∀ J, TaggedPrepartition J}
    (h : ∀ J ∈ π, l.MemBaseSet J c r (πi J)) (hp : ∀ J ∈ π, (πi J).IsPartition)
    (hc : l.bDistortion → π.compl.distortion ≤ c) : l.MemBaseSet I c r (π.biUnionTagged πi) := by
  refine' ⟨TaggedPrepartition.isSubordinate_biUnionTagged.2 fun J hJ => (h J hJ).1,
    fun hH => TaggedPrepartition.isHenstock_biUnionTagged.2 fun J hJ => (h J hJ).2 hH,
    fun hD => _, fun hD => _⟩
  · rw [Prepartition.distortion_biUnionTagged, Finset.sup_le_iff]
    exact fun J hJ => (h J hJ).3 hD
  · 

Proof state:
case refine'_2
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π✝ π₁ π₂ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
π : Prepartition I
πi : (J : Box ι) → TaggedPrepartition J
h : ∀ J ∈ π, MemBaseSet l J c r (πi J)
hp : ∀ J ∈ π, IsPartition (πi J)
hc : l.bDistortion = true → Prepartition.distortion (Prepartition.compl π) ≤ c
hD : l.bDistortion = true
⊢ ∃ π',
    Prepartition.iUnion π' = ↑I \ TaggedPrepartition.iUnion (Prepartition.biUnionTagged π πi) ∧
      Prepartition.distortion π' ≤ c

Next tactic:
refine' ⟨_, _, hc hD⟩
theorem biUnionTagged_memBaseSet {π : Prepartition I} {πi : ∀ J, TaggedPrepartition J}
    (h : ∀ J ∈ π, l.MemBaseSet J c r (πi J)) (hp : ∀ J ∈ π, (πi J).IsPartition)
    (hc : l.bDistortion → π.compl.distortion ≤ c) : l.MemBaseSet I c r (π.biUnionTagged πi) := by
  refine' ⟨TaggedPrepartition.isSubordinate_biUnionTagged.2 fun J hJ => (h J hJ).1,
    fun hH => TaggedPrepartition.isHenstock_biUnionTagged.2 fun J hJ => (h J hJ).2 hH,
    fun hD => _, fun hD => _⟩
  · rw [Prepartition.distortion_biUnionTagged, Finset.sup_le_iff]
    exact fun J hJ => (h J hJ).3 hD
  · refine' ⟨_, _, hc hD⟩
    

Proof state:
case refine'_2
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π✝ π₁ π₂ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
π : Prepartition I
πi : (J : Box ι) → TaggedPrepartition J
h : ∀ J ∈ π, MemBaseSet l J c r (πi J)
hp : ∀ J ∈ π, IsPartition (πi J)
hc : l.bDistortion = true → Prepartition.distortion (Prepartition.compl π) ≤ c
hD : l.bDistortion = true
⊢ Prepartition.iUnion (Prepartition.compl π) = ↑I \ TaggedPrepartition.iUnion (Prepartition.biUnionTagged π πi)

Next tactic:
rw [π.iUnion_compl, ← π.iUnion_biUnion_partition hp]
theorem biUnionTagged_memBaseSet {π : Prepartition I} {πi : ∀ J, TaggedPrepartition J}
    (h : ∀ J ∈ π, l.MemBaseSet J c r (πi J)) (hp : ∀ J ∈ π, (πi J).IsPartition)
    (hc : l.bDistortion → π.compl.distortion ≤ c) : l.MemBaseSet I c r (π.biUnionTagged πi) := by
  refine' ⟨TaggedPrepartition.isSubordinate_biUnionTagged.2 fun J hJ => (h J hJ).1,
    fun hH => TaggedPrepartition.isHenstock_biUnionTagged.2 fun J hJ => (h J hJ).2 hH,
    fun hD => _, fun hD => _⟩
  · rw [Prepartition.distortion_biUnionTagged, Finset.sup_le_iff]
    exact fun J hJ => (h J hJ).3 hD
  · refine' ⟨_, _, hc hD⟩
    rw [π.iUnion_compl, ← π.iUnion_biUnion_partition hp]
    

Proof state:
case refine'_2
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π✝ π₁ π₂ : TaggedPrepartition I
l l₁ l₂ : IntegrationParams
π : Prepartition I
πi : (J : Box ι) → TaggedPrepartition J
h : ∀ J ∈ π, MemBaseSet l J c r (πi J)
hp : ∀ J ∈ π, IsPartition (πi J)
hc : l.bDistortion = true → Prepartition.distortion (Prepartition.compl π) ≤ c
hD : l.bDistortion = true
⊢ ↑I \ Prepartition.iUnion (Prepartition.biUnion π fun J => (πi J).toPrepartition) =
    ↑I \ TaggedPrepartition.iUnion (Prepartition.biUnionTagged π πi)

Next tactic:
rfl
theorem toFilteriUnion_congr (I : Box ι) (l : IntegrationParams) {π₁ π₂ : Prepartition I}
    (h : π₁.iUnion = π₂.iUnion) : l.toFilteriUnion I π₁ = l.toFilteriUnion I π₂ := by
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁✝ π₂✝ : TaggedPrepartition I✝
l✝ l₁ l₂ : IntegrationParams
I : Box ι
l : IntegrationParams
π₁ π₂ : Prepartition I
h : Prepartition.iUnion π₁ = Prepartition.iUnion π₂
⊢ toFilteriUnion l I π₁ = toFilteriUnion l I π₂

Next tactic:
simp only [toFilteriUnion, toFilterDistortioniUnion, h]
theorem hasBasis_toFilteriUnion (l : IntegrationParams) (I : Box ι) (π₀ : Prepartition I) :
    (l.toFilteriUnion I π₀).HasBasis (fun r : ℝ≥0 → (ι → ℝ) → Ioi (0 : ℝ) => ∀ c, l.RCond (r c))
      fun r => { π | ∃ c, l.MemBaseSet I c (r c) π ∧ π.iUnion = π₀.iUnion } := by
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁ π₂ : TaggedPrepartition I✝
l✝ l₁ l₂ l : IntegrationParams
I : Box ι
π₀ : Prepartition I
⊢ HasBasis (toFilteriUnion l I π₀) (fun r => ∀ (c : ℝ≥0), RCond l (r c)) fun r =>
    {π | ∃ c, MemBaseSet l I c (r c) π ∧ TaggedPrepartition.iUnion π = Prepartition.iUnion π₀}

Next tactic:
have := fun c => l.hasBasis_toFilterDistortioniUnion I c π₀
theorem hasBasis_toFilteriUnion (l : IntegrationParams) (I : Box ι) (π₀ : Prepartition I) :
    (l.toFilteriUnion I π₀).HasBasis (fun r : ℝ≥0 → (ι → ℝ) → Ioi (0 : ℝ) => ∀ c, l.RCond (r c))
      fun r => { π | ∃ c, l.MemBaseSet I c (r c) π ∧ π.iUnion = π₀.iUnion } := by
  have := fun c => l.hasBasis_toFilterDistortioniUnion I c π₀
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁ π₂ : TaggedPrepartition I✝
l✝ l₁ l₂ l : IntegrationParams
I : Box ι
π₀ : Prepartition I
this :
  ∀ (c : ℝ≥0),
    HasBasis (toFilterDistortioniUnion l I c π₀) (RCond l) fun r =>
      {π | MemBaseSet l I c r π ∧ TaggedPrepartition.iUnion π = Prepartition.iUnion π₀}
⊢ HasBasis (toFilteriUnion l I π₀) (fun r => ∀ (c : ℝ≥0), RCond l (r c)) fun r =>
    {π | ∃ c, MemBaseSet l I c (r c) π ∧ TaggedPrepartition.iUnion π = Prepartition.iUnion π₀}

Next tactic:
simpa only [setOf_and, setOf_exists] using hasBasis_iSup this
theorem hasBasis_toFilteriUnion_top (l : IntegrationParams) (I : Box ι) :
    (l.toFilteriUnion I ⊤).HasBasis (fun r : ℝ≥0 → (ι → ℝ) → Ioi (0 : ℝ) => ∀ c, l.RCond (r c))
      fun r => { π | ∃ c, l.MemBaseSet I c (r c) π ∧ π.IsPartition } := by
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁ π₂ : TaggedPrepartition I✝
l✝ l₁ l₂ l : IntegrationParams
I : Box ι
⊢ HasBasis (toFilteriUnion l I ⊤) (fun r => ∀ (c : ℝ≥0), RCond l (r c)) fun r =>
    {π | ∃ c, MemBaseSet l I c (r c) π ∧ IsPartition π}

Next tactic:
simpa only [TaggedPrepartition.isPartition_iff_iUnion_eq, Prepartition.iUnion_top] using
    l.hasBasis_toFilteriUnion I ⊤
theorem hasBasis_toFilter (l : IntegrationParams) (I : Box ι) :
    (l.toFilter I).HasBasis (fun r : ℝ≥0 → (ι → ℝ) → Ioi (0 : ℝ) => ∀ c, l.RCond (r c))
      fun r => { π | ∃ c, l.MemBaseSet I c (r c) π } := by
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I✝ J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁ π₂ : TaggedPrepartition I✝
l✝ l₁ l₂ l : IntegrationParams
I : Box ι
⊢ HasBasis (toFilter l I) (fun r => ∀ (c : ℝ≥0), RCond l (r c)) fun r => {π | ∃ c, MemBaseSet l I c (r c) π}

Next tactic:
simpa only [setOf_exists] using hasBasis_iSup (l.hasBasis_toFilterDistortion I)
theorem tendsto_embedBox_toFilteriUnion_top (l : IntegrationParams) (h : I ≤ J) :
    Tendsto (TaggedPrepartition.embedBox I J h) (l.toFilteriUnion I ⊤)
      (l.toFilteriUnion J (Prepartition.single J I h)) := by
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁ π₂ : TaggedPrepartition I
l✝ l₁ l₂ l : IntegrationParams
h : I ≤ J
⊢ Tendsto (⇑(embedBox I J h)) (toFilteriUnion l I ⊤) (toFilteriUnion l J (Prepartition.single J I h))

Next tactic:
simp only [toFilteriUnion, tendsto_iSup]
theorem tendsto_embedBox_toFilteriUnion_top (l : IntegrationParams) (h : I ≤ J) :
    Tendsto (TaggedPrepartition.embedBox I J h) (l.toFilteriUnion I ⊤)
      (l.toFilteriUnion J (Prepartition.single J I h)) := by
  simp only [toFilteriUnion, tendsto_iSup]; 

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁ π₂ : TaggedPrepartition I
l✝ l₁ l₂ l : IntegrationParams
h : I ≤ J
⊢ ∀ (i : ℝ≥0),
    Tendsto (⇑(embedBox I J h)) (toFilterDistortioniUnion l I i ⊤)
      (⨆ c, toFilterDistortioniUnion l J c (Prepartition.single J I h))

Next tactic:
intro c
theorem tendsto_embedBox_toFilteriUnion_top (l : IntegrationParams) (h : I ≤ J) :
    Tendsto (TaggedPrepartition.embedBox I J h) (l.toFilteriUnion I ⊤)
      (l.toFilteriUnion J (Prepartition.single J I h)) := by
  simp only [toFilteriUnion, tendsto_iSup]; intro c
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c✝ c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁ π₂ : TaggedPrepartition I
l✝ l₁ l₂ l : IntegrationParams
h : I ≤ J
c : ℝ≥0
⊢ Tendsto (⇑(embedBox I J h)) (toFilterDistortioniUnion l I c ⊤)
    (⨆ c, toFilterDistortioniUnion l J c (Prepartition.single J I h))

Next tactic:
set π₀ := Prepartition.single J I h
theorem tendsto_embedBox_toFilteriUnion_top (l : IntegrationParams) (h : I ≤ J) :
    Tendsto (TaggedPrepartition.embedBox I J h) (l.toFilteriUnion I ⊤)
      (l.toFilteriUnion J (Prepartition.single J I h)) := by
  simp only [toFilteriUnion, tendsto_iSup]; intro c
  set π₀ := Prepartition.single J I h
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c✝ c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁ π₂ : TaggedPrepartition I
l✝ l₁ l₂ l : IntegrationParams
h : I ≤ J
c : ℝ≥0
π₀ : Prepartition J := Prepartition.single J I h
⊢ Tendsto (⇑(embedBox I J h)) (toFilterDistortioniUnion l I c ⊤) (⨆ c, toFilterDistortioniUnion l J c π₀)

Next tactic:
refine' le_iSup_of_le (max c π₀.compl.distortion) _
theorem tendsto_embedBox_toFilteriUnion_top (l : IntegrationParams) (h : I ≤ J) :
    Tendsto (TaggedPrepartition.embedBox I J h) (l.toFilteriUnion I ⊤)
      (l.toFilteriUnion J (Prepartition.single J I h)) := by
  simp only [toFilteriUnion, tendsto_iSup]; intro c
  set π₀ := Prepartition.single J I h
  refine' le_iSup_of_le (max c π₀.compl.distortion) _
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c✝ c₁ c₂ : ℝ≥0
r r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁ π₂ : TaggedPrepartition I
l✝ l₁ l₂ l : IntegrationParams
h : I ≤ J
c : ℝ≥0
π₀ : Prepartition J := Prepartition.single J I h
⊢ Filter.map (⇑(embedBox I J h)) (toFilterDistortioniUnion l I c ⊤) ≤
    toFilterDistortioniUnion l J (max c (Prepartition.distortion (Prepartition.compl π₀))) π₀

Next tactic:
refine' ((l.hasBasis_toFilterDistortioniUnion I c ⊤).tendsto_iff
    (l.hasBasis_toFilterDistortioniUnion J _ _)).2 fun r hr => _
theorem tendsto_embedBox_toFilteriUnion_top (l : IntegrationParams) (h : I ≤ J) :
    Tendsto (TaggedPrepartition.embedBox I J h) (l.toFilteriUnion I ⊤)
      (l.toFilteriUnion J (Prepartition.single J I h)) := by
  simp only [toFilteriUnion, tendsto_iSup]; intro c
  set π₀ := Prepartition.single J I h
  refine' le_iSup_of_le (max c π₀.compl.distortion) _
  refine' ((l.hasBasis_toFilterDistortioniUnion I c ⊤).tendsto_iff
    (l.hasBasis_toFilterDistortioniUnion J _ _)).2 fun r hr => _
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c✝ c₁ c₂ : ℝ≥0
r✝ r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π π₁ π₂ : TaggedPrepartition I
l✝ l₁ l₂ l : IntegrationParams
h : I ≤ J
c : ℝ≥0
π₀ : Prepartition J := Prepartition.single J I h
r : (ι → ℝ) → ↑(Set.Ioi 0)
hr : RCond l r
⊢ ∃ ia,
    RCond l ia ∧
      ∀ x ∈ {π | MemBaseSet l I c ia π ∧ TaggedPrepartition.iUnion π = Prepartition.iUnion ⊤},
        (embedBox I J h) x ∈
          {π |
            MemBaseSet l J (max c (Prepartition.distortion (Prepartition.compl π₀))) r π ∧
              TaggedPrepartition.iUnion π = Prepartition.iUnion π₀}

Next tactic:
refine' ⟨r, hr, fun π hπ => _⟩
theorem tendsto_embedBox_toFilteriUnion_top (l : IntegrationParams) (h : I ≤ J) :
    Tendsto (TaggedPrepartition.embedBox I J h) (l.toFilteriUnion I ⊤)
      (l.toFilteriUnion J (Prepartition.single J I h)) := by
  simp only [toFilteriUnion, tendsto_iSup]; intro c
  set π₀ := Prepartition.single J I h
  refine' le_iSup_of_le (max c π₀.compl.distortion) _
  refine' ((l.hasBasis_toFilterDistortioniUnion I c ⊤).tendsto_iff
    (l.hasBasis_toFilterDistortioniUnion J _ _)).2 fun r hr => _
  refine' ⟨r, hr, fun π hπ => _⟩
  

Proof state:
ι : Type u_1
inst✝ : Fintype ι
I J : Box ι
c✝ c₁ c₂ : ℝ≥0
r✝ r₁ r₂ : (ι → ℝ) → ↑(Set.Ioi 0)
π✝ π₁ π₂ : TaggedPrepartition I
l✝ l₁ l₂ l : IntegrationParams
h : I ≤ J
c : ℝ≥0
π₀ : Prepartition J := Prepartition.single J I h
r : (ι → ℝ) → ↑(Set.Ioi 0)
hr : RCond l r
π : TaggedPrepartition I
hπ : π ∈ {π | MemBaseSet l I c r π ∧ TaggedPrepartition.iUnion π = Prepartition.iUnion ⊤}
⊢ (embedBox I J h) π ∈
    {π |
      MemBaseSet l J (max c (Prepartition.distortion (Prepartition.compl π₀))) r π ∧
        TaggedPrepartition.iUnion π = Prepartition.iUnion π₀}

Next tactic:
rw [mem_setOf_eq, Prepartition.iUnion_top] at hπ