-- Mathlib/GroupTheory/CosetCover.lean
theorem leftCoset_cover_filter_FiniteIndex_aux
    [DecidablePred (FiniteIndex : Subgroup G → Prop)] :
    (⋃ k ∈ s.filter (fun i => (H i).FiniteIndex), g k • (H k : Set G) = Set.univ) ∧
      (1 ≤ ∑ i ∈ s, ((H i).index : ℚ)⁻¹) ∧
      (∑ i ∈ s, ((H i).index : ℚ)⁻¹ = 1 → Set.PairwiseDisjoint
        (s.filter (fun i => (H i).FiniteIndex)) (fun i ↦ g i • (H i : Set G)))

Proof state:
G : Type u_1
inst✝¹ : Group G
ι : Type u_2
H : ι → Subgroup G
g : ι → G
s : Finset ι
inst✝ : DecidablePred FiniteIndex
hcovers :
  ⋃ i ∈ Finset.filter (fun i => (H i).FiniteIndex) s ∪ Finset.filter (fun a => ¬(H a).FiniteIndex) s, g i • ↑(H i) =
    Set.univ
D : Subgroup G := ⨅ k ∈ Finset.filter (fun i => (H i).FiniteIndex) s, H k
hD : D.FiniteIndex
hD_le : ∀ {i : ι}, i ∈ s → (H i).FiniteIndex → D ≤ H i
t : (i : ι) → i ∈ s → (H i).FiniteIndex → Finset ↥(H i)
ht :
  ∀ (i : ι) (hi : i ∈ s) (hfi : (H i).FiniteIndex),
    IsComplement ↑(t i hi hfi) ↑(D.subgroupOf (H i)) ∧ ⋃ g ∈ t i hi hfi, ↑g • ↑D = ↑(H i)
κ : Type (max u_2 u_1) := (i : { x // x ∈ s }) × { x // x ∈ if h : (H ↑i).FiniteIndex then t ↑i ⋯ h else {1} }
f : κ → G := fun k => g ↑k.fst * ↑↑k.snd
K : κ → Subgroup G := fun k => if (H ↑k.fst).FiniteIndex then D else H ↑k.fst
⊢ ⋃ k ∈ Finset.univ, f k • ↑(K k) = Set.univ

Tactic:
rw [← hcovers, ← Finset.univ.filter_union_filter_neg_eq (fun k => (H k.1).FiniteIndex),
  Finset.set_biUnion_union, Finset.set_biUnion_union]

Result:
G : Type u_1
inst✝¹ : Group G
ι : Type u_2
H : ι → Subgroup G
g : ι → G
s : Finset ι
inst✝ : DecidablePred FiniteIndex
hcovers :
  ⋃ i ∈ Finset.filter (fun i => (H i).FiniteIndex) s ∪ Finset.filter (fun a => ¬(H a).FiniteIndex) s, g i • ↑(H i) =
    Set.univ
D : Subgroup G := ⨅ k ∈ Finset.filter (fun i => (H i).FiniteIndex) s, H k
hD : D.FiniteIndex
hD_le : ∀ {i : ι}, i ∈ s → (H i).FiniteIndex → D ≤ H i
t : (i : ι) → i ∈ s → (H i).FiniteIndex → Finset ↥(H i)
ht :
  ∀ (i : ι) (hi : i ∈ s) (hfi : (H i).FiniteIndex),
    IsComplement ↑(t i hi hfi) ↑(D.subgroupOf (H i)) ∧ ⋃ g ∈ t i hi hfi, ↑g • ↑D = ↑(H i)
κ : Type (max u_2 u_1) := (i : { x // x ∈ s }) × { x // x ∈ if h : (H ↑i).FiniteIndex then t ↑i ⋯ h else {1} }
f : κ → G := fun k => g ↑k.fst * ↑↑k.snd
K : κ → Subgroup G := fun k => if (H ↑k.fst).FiniteIndex then D else H ↑k.fst
⊢ (⋃ x ∈ Finset.filter (fun k => (H ↑k.fst).FiniteIndex) Finset.univ, f x • ↑(K x)) ∪
      ⋃ x ∈ Finset.filter (fun a => ¬(H ↑a.fst).FiniteIndex) Finset.univ, f x • ↑(K x) =
    (⋃ x ∈ Finset.filter (fun i => (H i).FiniteIndex) s, g x • ↑(H x)) ∪
      ⋃ x ∈ Finset.filter (fun a => ¬(H a).FiniteIndex) s, g x • ↑(H x)

Proof state:
G : Type u_1
inst✝¹ : Group G
ι : Type u_2
H : ι → Subgroup G
g : ι → G
s : Finset ι
hcovers : ⋃ i ∈ s, g i • ↑(H i) = Set.univ
inst✝ : DecidablePred FiniteIndex
D : Subgroup G := ⨅ k ∈ Finset.filter (fun i => (H i).FiniteIndex) s, H k
hD : D.FiniteIndex
hD_le : ∀ {i : ι}, i ∈ s → (H i).FiniteIndex → D ≤ H i
t : (i : ι) → i ∈ s → (H i).FiniteIndex → Finset ↥(H i)
ht :
  ∀ (i : ι) (hi : i ∈ s) (hfi : (H i).FiniteIndex),
    IsComplement ↑(t i hi hfi) ↑(D.subgroupOf (H i)) ∧ ⋃ g ∈ t i hi hfi, ↑g • ↑D = ↑(H i)
κ : Type (max u_2 u_1) := (i : { x // x ∈ s }) × { x // x ∈ if h : (H ↑i).FiniteIndex then t ↑i ⋯ h else {1} }
f : κ → G := fun k => g ↑k.fst * ↑↑k.snd
K : κ → Subgroup G := fun k => if (H ↑k.fst).FiniteIndex then D else H ↑k.fst
hcovers' : ⋃ k ∈ Finset.univ, f k • ↑(K k) = Set.univ
⊢ ⋃ k ∈ Finset.filter (fun i => (H i).FiniteIndex) s, g k • ↑(H k) = Set.univ ∧
    1 ≤ ∑ i ∈ s, (↑(H i).index)⁻¹ ∧
      (∑ i ∈ s, (↑(H i).index)⁻¹ = 1 →
        (↑(Finset.filter (fun i => (H i).FiniteIndex) s)).PairwiseDisjoint fun i => g i • ↑(H i))

Tactic:
have ⟨k, hkfi, hk⟩ : ∃ k, (H k.1.1).FiniteIndex ∧ K k = D :=
  have ⟨j, hj, hjfi⟩ := exists_finiteIndex_of_leftCoset_cover hcovers
  have ⟨x, hx⟩ : (t j hj hjfi).Nonempty := Finset.nonempty_coe_sort.mp
    (ht j hj hjfi).1.leftQuotientEquiv.symm.nonempty
  ⟨⟨⟨j, hj⟩, ⟨x, dif_pos hjfi ▸ hx⟩⟩, hjfi, if_pos hjfi⟩

Result:
G : Type u_1
inst✝¹ : Group G
ι : Type u_2
H : ι → Subgroup G
g : ι → G
s : Finset ι
hcovers : ⋃ i ∈ s, g i • ↑(H i) = Set.univ
inst✝ : DecidablePred FiniteIndex
D : Subgroup G := ⨅ k ∈ Finset.filter (fun i => (H i).FiniteIndex) s, H k
hD : D.FiniteIndex
hD_le : ∀ {i : ι}, i ∈ s → (H i).FiniteIndex → D ≤ H i
t : (i : ι) → i ∈ s → (H i).FiniteIndex → Finset ↥(H i)
ht :
  ∀ (i : ι) (hi : i ∈ s) (hfi : (H i).FiniteIndex),
    IsComplement ↑(t i hi hfi) ↑(D.subgroupOf (H i)) ∧ ⋃ g ∈ t i hi hfi, ↑g • ↑D = ↑(H i)
κ : Type (max u_2 u_1) := (i : { x // x ∈ s }) × { x // x ∈ if h : (H ↑i).FiniteIndex then t ↑i ⋯ h else {1} }
f : κ → G := fun k => g ↑k.fst * ↑↑k.snd
K : κ → Subgroup G := fun k => if (H ↑k.fst).FiniteIndex then D else H ↑k.fst
hcovers' : ⋃ k ∈ Finset.univ, f k • ↑(K k) = Set.univ
k : κ
hkfi : (H ↑k.fst).FiniteIndex
hk : K k = D
⊢ ⋃ k ∈ Finset.filter (fun i => (H i).FiniteIndex) s, g k • ↑(H k) = Set.univ ∧
    1 ≤ ∑ i ∈ s, (↑(H i).index)⁻¹ ∧
      (∑ i ∈ s, (↑(H i).index)⁻¹ = 1 →
        (↑(Finset.filter (fun i => (H i).FiniteIndex) s)).PairwiseDisjoint fun i => g i • ↑(H i))

Proof state:
case refine_1
G : Type u_1
inst✝¹ : Group G
ι : Type u_2
H : ι → Subgroup G
g : ι → G
s : Finset ι
hcovers : ⋃ i ∈ s, g i • ↑(H i) = Set.univ
inst✝ : DecidablePred FiniteIndex
D : Subgroup G := ⨅ k ∈ Finset.filter (fun i => (H i).FiniteIndex) s, H k
hD : D.FiniteIndex
hD_le : ∀ {i : ι}, i ∈ s → (H i).FiniteIndex → D ≤ H i
t : (i : ι) → i ∈ s → (H i).FiniteIndex → Finset ↥(H i)
ht :
  ∀ (i : ι) (hi : i ∈ s) (hfi : (H i).FiniteIndex),
    IsComplement ↑(t i hi hfi) ↑(D.subgroupOf (H i)) ∧ ⋃ g ∈ t i hi hfi, ↑g • ↑D = ↑(H i)
κ : Type (max u_2 u_1) := (i : { x // x ∈ s }) × { x // x ∈ if h : (H ↑i).FiniteIndex then t ↑i ⋯ h else {1} }
f : κ → G := fun k => g ↑k.fst * ↑↑k.snd
K : κ → Subgroup G := fun k => if (H ↑k.fst).FiniteIndex then D else H ↑k.fst
k : κ
hkfi : (H ↑k.fst).FiniteIndex
hk : K k = D
hcovers' : ⋃ i ∈ Finset.filter (fun x => K x = D) Finset.univ, f i • ↑D = Set.univ
hHD : ∀ (i : ι), ¬(H i).FiniteIndex → H i ≠ D
hdensity : ∑ i ∈ s, (↑(H i).index)⁻¹ = ↑(Finset.filter (fun x => K x = D) Finset.univ).card * (↑D.index)⁻¹
i : ι
⊢ ⋃ (_ : i ∈ s), ⋃ (_ : (H i).FiniteIndex), g i • ↑(H i) =
    ⋃ (hx : i ∈ s), ⋃ a, ⋃ (_ : ⟨⟨i, hx⟩, a⟩ ∈ Finset.filter (fun x => K x = D) Finset.univ), f ⟨⟨i, hx⟩, a⟩ • ↑D

Tactic:
refine Set.iUnion_congr fun hi => ?_

Result:
case refine_1
G : Type u_1
inst✝¹ : Group G
ι : Type u_2
H : ι → Subgroup G
g : ι → G
s : Finset ι
hcovers : ⋃ i ∈ s, g i • ↑(H i) = Set.univ
inst✝ : DecidablePred FiniteIndex
D : Subgroup G := ⨅ k ∈ Finset.filter (fun i => (H i).FiniteIndex) s, H k
hD : D.FiniteIndex
hD_le : ∀ {i : ι}, i ∈ s → (H i).FiniteIndex → D ≤ H i
t : (i : ι) → i ∈ s → (H i).FiniteIndex → Finset ↥(H i)
ht :
  ∀ (i : ι) (hi : i ∈ s) (hfi : (H i).FiniteIndex),
    IsComplement ↑(t i hi hfi) ↑(D.subgroupOf (H i)) ∧ ⋃ g ∈ t i hi hfi, ↑g • ↑D = ↑(H i)
κ : Type (max u_2 u_1) := (i : { x // x ∈ s }) × { x // x ∈ if h : (H ↑i).FiniteIndex then t ↑i ⋯ h else {1} }
f : κ → G := fun k => g ↑k.fst * ↑↑k.snd
K : κ → Subgroup G := fun k => if (H ↑k.fst).FiniteIndex then D else H ↑k.fst
k : κ
hkfi : (H ↑k.fst).FiniteIndex
hk : K k = D
hcovers' : ⋃ i ∈ Finset.filter (fun x => K x = D) Finset.univ, f i • ↑D = Set.univ
hHD : ∀ (i : ι), ¬(H i).FiniteIndex → H i ≠ D
hdensity : ∑ i ∈ s, (↑(H i).index)⁻¹ = ↑(Finset.filter (fun x => K x = D) Finset.univ).card * (↑D.index)⁻¹
i : ι
hi : i ∈ s
⊢ ⋃ (_ : (H i).FiniteIndex), g i • ↑(H i) =
    ⋃ a, ⋃ (_ : ⟨⟨i, hi⟩, a⟩ ∈ Finset.filter (fun x => K x = D) Finset.univ), f ⟨⟨i, hi⟩, a⟩ • ↑D