l3lab/ntp-mathlib huggingface dataset:
@[to_additive]
theorem mem_rightTransversals_iff_existsUnique_mul_inv_mem :
    S ∈ rightTransversals T ↔ ∀ g : G, ∃! s : S, g * (s : G)⁻¹ ∈ T := by
  rw [rightTransversals, Set.mem_setOf_eq, isComplement_iff_existsUnique]
  refine' ⟨fun h g => _, fun h g => _⟩
  · obtain ⟨x, h1, h2⟩ := h g
    exact
      ⟨x.2, (congr_arg (· ∈ T) (eq_mul_inv_of_mul_eq h1)).mp x.1.2, fun y hy =>
        (Prod.ext_iff.mp (h2 ⟨⟨g * (↑y)⁻¹, hy⟩, y⟩ (inv_mul_cancel_right g y))).2⟩
  · obtain ⟨x, h1, h2⟩ := h g
    refine' ⟨⟨⟨g * (↑x)⁻¹, h1⟩, x⟩, inv_mul_cancel_right g x, fun y hy => _⟩
    have hf := h2 y.2 ((congr_arg (· ∈ T) (eq_mul_inv_of_mul_eq hy)).mp y.1.2)
    

Proof state:
case refine'_2.intro.intro
G : Type u_1
inst✝ : Group G
H K : Subgroup G
S T : Set G
h : ∀ (g : G), ∃! s, g * (↑s)⁻¹ ∈ T
g : G
x : ↑S
h1 : g * (↑x)⁻¹ ∈ T
h2 : ∀ (y : ↑S), (fun s => g * (↑s)⁻¹ ∈ T) y → y = x
y : ↑T × ↑S
hy : (fun x => ↑x.1 * ↑x.2 = g) y
hf : y.2 = x
⊢ y = ({ val := g * (↑x)⁻¹, property := h1 }, x)

Next tactic:
exact Prod.ext (Subtype.ext (eq_mul_inv_of_mul_eq (hf ▸ hy))) hf
@[to_additive]
theorem mem_leftTransversals_iff_existsUnique_quotient_mk''_eq :
    S ∈ leftTransversals (H : Set G) ↔
      ∀ q : Quotient (QuotientGroup.leftRel H), ∃! s : S, Quotient.mk'' s.1 = q := by
  

Proof state:
G : Type u_1
inst✝ : Group G
H K : Subgroup G
S T : Set G
⊢ S ∈ leftTransversals ↑H ↔ ∀ (q : Quotient (QuotientGroup.leftRel H)), ∃! s, Quotient.mk'' ↑s = q

Next tactic:
simp_rw [mem_leftTransversals_iff_existsUnique_inv_mul_mem, SetLike.mem_coe, ←
    QuotientGroup.eq']
@[to_additive]
theorem mem_leftTransversals_iff_existsUnique_quotient_mk''_eq :
    S ∈ leftTransversals (H : Set G) ↔
      ∀ q : Quotient (QuotientGroup.leftRel H), ∃! s : S, Quotient.mk'' s.1 = q := by
  simp_rw [mem_leftTransversals_iff_existsUnique_inv_mul_mem, SetLike.mem_coe, ←
    QuotientGroup.eq']
  

Proof state:
G : Type u_1
inst✝ : Group G
H K : Subgroup G
S T : Set G
⊢ (∀ (g : G), ∃! s, ↑↑s = ↑g) ↔ ∀ (q : Quotient (QuotientGroup.leftRel H)), ∃! s, Quotient.mk'' ↑s = q

Next tactic:
exact ⟨fun h q => Quotient.inductionOn' q h, fun h g => h (Quotient.mk'' g)⟩
@[to_additive]
theorem mem_rightTransversals_iff_existsUnique_quotient_mk''_eq :
    S ∈ rightTransversals (H : Set G) ↔
      ∀ q : Quotient (QuotientGroup.rightRel H), ∃! s : S, Quotient.mk'' s.1 = q := by
  

Proof state:
G : Type u_1
inst✝ : Group G
H K : Subgroup G
S T : Set G
⊢ S ∈ rightTransversals ↑H ↔ ∀ (q : Quotient (QuotientGroup.rightRel H)), ∃! s, Quotient.mk'' ↑s = q

Next tactic:
simp_rw [mem_rightTransversals_iff_existsUnique_mul_inv_mem, SetLike.mem_coe, ←
    QuotientGroup.rightRel_apply, ← Quotient.eq'']
@[to_additive]
theorem mem_rightTransversals_iff_existsUnique_quotient_mk''_eq :
    S ∈ rightTransversals (H : Set G) ↔
      ∀ q : Quotient (QuotientGroup.rightRel H), ∃! s : S, Quotient.mk'' s.1 = q := by
  simp_rw [mem_rightTransversals_iff_existsUnique_mul_inv_mem, SetLike.mem_coe, ←
    QuotientGroup.rightRel_apply, ← Quotient.eq'']
  

Proof state:
G : Type u_1
inst✝ : Group G
H K : Subgroup G
S T : Set G
⊢ (∀ (g : G), ∃! s, Quotient.mk'' ↑s = Quotient.mk'' g) ↔
    ∀ (q : Quotient (QuotientGroup.rightRel H)), ∃! s, Quotient.mk'' ↑s = q

Next tactic:
exact ⟨fun h q => Quotient.inductionOn' q h, fun h g => h (Quotient.mk'' g)⟩
@[to_additive]
theorem range_mem_leftTransversals {f : G ⧸ H → G} (hf : ∀ q, ↑(f q) = q) :
    Set.range f ∈ leftTransversals (H : Set G) :=
  mem_leftTransversals_iff_bijective.mpr
    ⟨by 

Proof state:
G : Type u_1
inst✝ : Group G
H K : Subgroup G
S T : Set G
f : G ⧸ H → G
hf : ∀ (q : G ⧸ H), ↑(f q) = q
⊢ Function.Injective (restrict (range f) Quotient.mk'')

Next tactic:
rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h
@[to_additive]
theorem range_mem_leftTransversals {f : G ⧸ H → G} (hf : ∀ q, ↑(f q) = q) :
    Set.range f ∈ leftTransversals (H : Set G) :=
  mem_leftTransversals_iff_bijective.mpr
    ⟨by rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h
        

Proof state:
case mk.intro.mk.intro
G : Type u_1
inst✝ : Group G
H K : Subgroup G
S T : Set G
f : G ⧸ H → G
hf : ∀ (q : G ⧸ H), ↑(f q) = q
q₁ q₂ : G ⧸ H
h :
  restrict (range f) Quotient.mk'' { val := f q₁, property := (_ : ∃ y, f y = f q₁) } =
    restrict (range f) Quotient.mk'' { val := f q₂, property := (_ : ∃ y, f y = f q₂) }
⊢ { val := f q₁, property := (_ : ∃ y, f y = f q₁) } = { val := f q₂, property := (_ : ∃ y, f y = f q₂) }

Next tactic:
exact Subtype.ext $ congr_arg f $ ((hf q₁).symm.trans h).trans (hf q₂)
@[to_additive]
theorem range_mem_rightTransversals {f : Quotient (QuotientGroup.rightRel H) → G}
    (hf : ∀ q, Quotient.mk'' (f q) = q) : Set.range f ∈ rightTransversals (H : Set G) :=
  mem_rightTransversals_iff_bijective.mpr
    ⟨by 

Proof state:
G : Type u_1
inst✝ : Group G
H K : Subgroup G
S T : Set G
f : Quotient (QuotientGroup.rightRel H) → G
hf : ∀ (q : Quotient (QuotientGroup.rightRel H)), Quotient.mk'' (f q) = q
⊢ Function.Injective (restrict (range f) Quotient.mk'')

Next tactic:
rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h
@[to_additive]
theorem range_mem_rightTransversals {f : Quotient (QuotientGroup.rightRel H) → G}
    (hf : ∀ q, Quotient.mk'' (f q) = q) : Set.range f ∈ rightTransversals (H : Set G) :=
  mem_rightTransversals_iff_bijective.mpr
    ⟨by rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h
        

Proof state:
case mk.intro.mk.intro
G : Type u_1
inst✝ : Group G
H K : Subgroup G
S T : Set G
f : Quotient (QuotientGroup.rightRel H) → G
hf : ∀ (q : Quotient (QuotientGroup.rightRel H)), Quotient.mk'' (f q) = q
q₁ q₂ : Quotient (QuotientGroup.rightRel H)
h :
  restrict (range f) Quotient.mk'' { val := f q₁, property := (_ : ∃ y, f y = f q₁) } =
    restrict (range f) Quotient.mk'' { val := f q₂, property := (_ : ∃ y, f y = f q₂) }
⊢ { val := f q₁, property := (_ : ∃ y, f y = f q₁) } = { val := f q₂, property := (_ : ∃ y, f y = f q₂) }

Next tactic:
exact Subtype.ext $ congr_arg f $ ((hf q₁).symm.trans h).trans (hf q₂)
@[to_additive]
lemma exists_left_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ leftTransversals (H : Set G), g ∈ S := by
  

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
⊢ ∃ S ∈ leftTransversals ↑H, g ∈ S

Next tactic:
classical
    refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_leftTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
    by_cases hq : q = Quotient.mk'' g
    · exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out')
    · refine' (Function.update_noteq _ g Quotient.out') ▸ q.out_eq'
      exact hq
@[to_additive]
lemma exists_left_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ leftTransversals (H : Set G), g ∈ S := by
  classical
    

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
⊢ ∃ S ∈ leftTransversals ↑H, g ∈ S

Next tactic:
refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_leftTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
@[to_additive]
lemma exists_left_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ leftTransversals (H : Set G), g ∈ S := by
  classical
    refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_leftTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
    

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
q : G ⧸ H
⊢ ↑(Function.update Quotient.out' (Quotient.mk'' g) g q) = q

Next tactic:
by_cases hq : q = Quotient.mk'' g
@[to_additive]
lemma exists_left_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ leftTransversals (H : Set G), g ∈ S := by
  classical
    refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_leftTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
    by_cases hq : q = Quotient.mk'' g
    · 

Proof state:
case pos
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
q : G ⧸ H
hq : q = Quotient.mk'' g
⊢ ↑(Function.update Quotient.out' (Quotient.mk'' g) g q) = q

Next tactic:
exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out')
@[to_additive]
lemma exists_left_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ leftTransversals (H : Set G), g ∈ S := by
  classical
    refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_leftTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
    by_cases hq : q = Quotient.mk'' g
    · exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out')
    · 

Proof state:
case neg
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
q : G ⧸ H
hq : ¬q = Quotient.mk'' g
⊢ ↑(Function.update Quotient.out' (Quotient.mk'' g) g q) = q

Next tactic:
refine' (Function.update_noteq _ g Quotient.out') ▸ q.out_eq'
@[to_additive]
lemma exists_left_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ leftTransversals (H : Set G), g ∈ S := by
  classical
    refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_leftTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
    by_cases hq : q = Quotient.mk'' g
    · exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out')
    · refine' (Function.update_noteq _ g Quotient.out') ▸ q.out_eq'
      

Proof state:
case neg
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
q : G ⧸ H
hq : ¬q = Quotient.mk'' g
⊢ q ≠ Quotient.mk'' g

Next tactic:
exact hq
@[to_additive]
lemma exists_right_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ rightTransversals (H : Set G), g ∈ S := by
  

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
⊢ ∃ S ∈ rightTransversals ↑H, g ∈ S

Next tactic:
classical
    refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_rightTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
    by_cases hq : q = Quotient.mk'' g
    · exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out')
    · exact Eq.trans (congr_arg _ (Function.update_noteq hq g Quotient.out')) q.out_eq'
@[to_additive]
lemma exists_right_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ rightTransversals (H : Set G), g ∈ S := by
  classical
    

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
⊢ ∃ S ∈ rightTransversals ↑H, g ∈ S

Next tactic:
refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_rightTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
@[to_additive]
lemma exists_right_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ rightTransversals (H : Set G), g ∈ S := by
  classical
    refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_rightTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
    

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
q : Quotient (QuotientGroup.rightRel H)
⊢ Quotient.mk'' (Function.update Quotient.out' (Quotient.mk'' g) g q) = q

Next tactic:
by_cases hq : q = Quotient.mk'' g
@[to_additive]
lemma exists_right_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ rightTransversals (H : Set G), g ∈ S := by
  classical
    refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_rightTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
    by_cases hq : q = Quotient.mk'' g
    · 

Proof state:
case pos
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
q : Quotient (QuotientGroup.rightRel H)
hq : q = Quotient.mk'' g
⊢ Quotient.mk'' (Function.update Quotient.out' (Quotient.mk'' g) g q) = q

Next tactic:
exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out')
@[to_additive]
lemma exists_right_transversal (H : Subgroup G) (g : G) :
    ∃ S ∈ rightTransversals (H : Set G), g ∈ S := by
  classical
    refine'
      ⟨Set.range (Function.update Quotient.out' _ g), range_mem_rightTransversals fun q => _,
        Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩
    by_cases hq : q = Quotient.mk'' g
    · exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out')
    · 

Proof state:
case neg
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H : Subgroup G
g : G
q : Quotient (QuotientGroup.rightRel H)
hq : ¬q = Quotient.mk'' g
⊢ Quotient.mk'' (Function.update Quotient.out' (Quotient.mk'' g) g q) = q

Next tactic:
exact Eq.trans (congr_arg _ (Function.update_noteq hq g Quotient.out')) q.out_eq'
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H' H : Subgroup G
h : H' ≤ H
⊢ ∃ S, S * ↑H' = ↑H ∧ Nat.card ↑S * Nat.card ↥H' = Nat.card ↥H

Next tactic:
let H'' : Subgroup H := H'.comap H.subtype
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
⊢ ∃ S, S * ↑H' = ↑H ∧ Nat.card ↑S * Nat.card ↥H' = Nat.card ↥H

Next tactic:
have : H' = H''.map H.subtype := by simp [h]
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  have : H' = H''.map H.subtype := by 

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
⊢ H' = map (Subgroup.subtype H) H''

Next tactic:
simp [h]
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  have : H' = H''.map H.subtype := by simp [h]
  

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
this : H' = map (Subgroup.subtype H) H''
⊢ ∃ S, S * ↑H' = ↑H ∧ Nat.card ↑S * Nat.card ↥H' = Nat.card ↥H

Next tactic:
rw [this]
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  have : H' = H''.map H.subtype := by simp [h]
  rw [this]
  

Proof state:
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
this : H' = map (Subgroup.subtype H) H''
⊢ ∃ S, S * ↑(map (Subgroup.subtype H) H'') = ↑H ∧ Nat.card ↑S * Nat.card ↥(map (Subgroup.subtype H) H'') = Nat.card ↥H

Next tactic:
obtain ⟨S, cmem, -⟩ := H''.exists_left_transversal 1
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  have : H' = H''.map H.subtype := by simp [h]
  rw [this]
  obtain ⟨S, cmem, -⟩ := H''.exists_left_transversal 1
  

Proof state:
case intro.intro
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S✝ T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
this : H' = map (Subgroup.subtype H) H''
S : Set ↥H
cmem : S ∈ leftTransversals ↑H''
⊢ ∃ S, S * ↑(map (Subgroup.subtype H) H'') = ↑H ∧ Nat.card ↑S * Nat.card ↥(map (Subgroup.subtype H) H'') = Nat.card ↥H

Next tactic:
refine ⟨H.subtype '' S, ?_, ?_⟩
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  have : H' = H''.map H.subtype := by simp [h]
  rw [this]
  obtain ⟨S, cmem, -⟩ := H''.exists_left_transversal 1
  refine ⟨H.subtype '' S, ?_, ?_⟩
  · 

Proof state:
case intro.intro.refine_1
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S✝ T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
this : H' = map (Subgroup.subtype H) H''
S : Set ↥H
cmem : S ∈ leftTransversals ↑H''
⊢ ⇑(Subgroup.subtype H) '' S * ↑(map (Subgroup.subtype H) H'') = ↑H

Next tactic:
have : H.subtype '' (S * H'') = H.subtype '' S * H''.map H.subtype := image_mul H.subtype
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  have : H' = H''.map H.subtype := by simp [h]
  rw [this]
  obtain ⟨S, cmem, -⟩ := H''.exists_left_transversal 1
  refine ⟨H.subtype '' S, ?_, ?_⟩
  · have : H.subtype '' (S * H'') = H.subtype '' S * H''.map H.subtype := image_mul H.subtype
    

Proof state:
case intro.intro.refine_1
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S✝ T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
this✝ : H' = map (Subgroup.subtype H) H''
S : Set ↥H
cmem : S ∈ leftTransversals ↑H''
this : ⇑(Subgroup.subtype H) '' (S * ↑H'') = ⇑(Subgroup.subtype H) '' S * ↑(map (Subgroup.subtype H) H'')
⊢ ⇑(Subgroup.subtype H) '' S * ↑(map (Subgroup.subtype H) H'') = ↑H

Next tactic:
rw [← this, cmem.mul_eq]
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  have : H' = H''.map H.subtype := by simp [h]
  rw [this]
  obtain ⟨S, cmem, -⟩ := H''.exists_left_transversal 1
  refine ⟨H.subtype '' S, ?_, ?_⟩
  · have : H.subtype '' (S * H'') = H.subtype '' S * H''.map H.subtype := image_mul H.subtype
    rw [← this, cmem.mul_eq]
    

Proof state:
case intro.intro.refine_1
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S✝ T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
this✝ : H' = map (Subgroup.subtype H) H''
S : Set ↥H
cmem : S ∈ leftTransversals ↑H''
this : ⇑(Subgroup.subtype H) '' (S * ↑H'') = ⇑(Subgroup.subtype H) '' S * ↑(map (Subgroup.subtype H) H'')
⊢ ⇑(Subgroup.subtype H) '' univ = ↑H

Next tactic:
simp [Set.ext_iff]
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  have : H' = H''.map H.subtype := by simp [h]
  rw [this]
  obtain ⟨S, cmem, -⟩ := H''.exists_left_transversal 1
  refine ⟨H.subtype '' S, ?_, ?_⟩
  · have : H.subtype '' (S * H'') = H.subtype '' S * H''.map H.subtype := image_mul H.subtype
    rw [← this, cmem.mul_eq]
    simp [Set.ext_iff]
  · 

Proof state:
case intro.intro.refine_2
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S✝ T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
this : H' = map (Subgroup.subtype H) H''
S : Set ↥H
cmem : S ∈ leftTransversals ↑H''
⊢ Nat.card ↑(⇑(Subgroup.subtype H) '' S) * Nat.card ↥(map (Subgroup.subtype H) H'') = Nat.card ↥H

Next tactic:
rw [← cmem.card_mul_card]
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  have : H' = H''.map H.subtype := by simp [h]
  rw [this]
  obtain ⟨S, cmem, -⟩ := H''.exists_left_transversal 1
  refine ⟨H.subtype '' S, ?_, ?_⟩
  · have : H.subtype '' (S * H'') = H.subtype '' S * H''.map H.subtype := image_mul H.subtype
    rw [← this, cmem.mul_eq]
    simp [Set.ext_iff]
  · rw [← cmem.card_mul_card]
    

Proof state:
case intro.intro.refine_2
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S✝ T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
this : H' = map (Subgroup.subtype H) H''
S : Set ↥H
cmem : S ∈ leftTransversals ↑H''
⊢ Nat.card ↑(⇑(Subgroup.subtype H) '' S) * Nat.card ↥(map (Subgroup.subtype H) H'') = Nat.card ↑S * Nat.card ↑↑H''

Next tactic:
refine congr_arg₂ (· * ·) ?_ ?_
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
    ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
  let H'' : Subgroup H := H'.comap H.subtype
  have : H' = H''.map H.subtype := by simp [h]
  rw [this]
  obtain ⟨S, cmem, -⟩ := H''.exists_left_transversal 1
  refine ⟨H.subtype '' S, ?_, ?_⟩
  · have : H.subtype '' (S * H'') = H.subtype '' S * H''.map H.subtype := image_mul H.subtype
    rw [← this, cmem.mul_eq]
    simp [Set.ext_iff]
  · rw [← cmem.card_mul_card]
    refine congr_arg₂ (· * ·) ?_ ?_ <;>
      

Proof state:
case intro.intro.refine_2.refine_1
G : Type u_1
inst✝ : Group G
H✝ K : Subgroup G
S✝ T : Set G
H' H : Subgroup G
h : H' ≤ H
H'' : Subgroup ↥H := comap (Subgroup.subtype H) H'
this : H' = map (Subgroup.subtype H) H''
S : Set ↥H
cmem : S ∈ leftTransversals ↑H''
⊢ Nat.card ↑(⇑(Subgroup.subtype H) '' S) = Nat.card ↑S

Next tactic:
exact Nat.card_congr (Equiv.Set.image _ _ $ subtype_injective H).symm