l3lab/ntp-mathlib huggingface dataset:
theorem isThreeCycle_cycleRange_two {n : ℕ} : IsThreeCycle (cycleRange 2 : Perm (Fin (n + 3))) := by
  rw [IsThreeCycle, cycleType_cycleRange] <;> 

Proof state:
n : ℕ
⊢ {↑2 + 1} = {3}

Next tactic:
simp [Fin.eq_iff_veq]
theorem isThreeCycle_cycleRange_two {n : ℕ} : IsThreeCycle (cycleRange 2 : Perm (Fin (n + 3))) := by
  rw [IsThreeCycle, cycleType_cycleRange] <;> 

Proof state:
n : ℕ
⊢ 2 ≠ 0

Next tactic:
simp [Fin.eq_iff_veq]
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  

Proof state:
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
⊢ ↑(closure ((fun g => g * (↑(toFun hR g))⁻¹) '' (R * S))) * R = ⊤

Next tactic:
let f : G → R := fun g => toFun hR g
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  

Proof state:
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
⊢ ↑(closure ((fun g => g * (↑(toFun hR g))⁻¹) '' (R * S))) * R = ⊤

Next tactic:
let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  

Proof state:
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
⊢ ↑(closure ((fun g => g * (↑(toFun hR g))⁻¹) '' (R * S))) * R = ⊤

Next tactic:
change (closure U : Set G) * R = ⊤
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  

Proof state:
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
⊢ ↑(closure U) * R = ⊤

Next tactic:
refine' top_le_iff.mp fun g _ => _
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  

Proof state:
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
⊢ g ∈ ↑(closure U) * R

Next tactic:
apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · 

Proof state:
case H1
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
⊢ 1 ∈ ↑(closure U) * R

Next tactic:
exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · 

Proof state:
case Hmul
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
⊢ ∀ (x y : G), y ∈ S → x ∈ ↑(closure U) * R → x * y ∈ ↑(closure U) * R

Next tactic:
rintro - s hs ⟨u, r, hu, hr, rfl⟩
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    

Proof state:
case Hmul.intro.intro.intro.intro
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ (fun x x_1 => x * x_1) u r * s ∈ ↑(closure U) * R

Next tactic:
rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by 

Proof state:
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ u * r * s = u * (r * s * (↑(f (r * s)))⁻¹) * ↑(f (r * s))

Next tactic:
group
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    

Proof state:
case Hmul.intro.intro.intro.intro
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ u * (r * s * (↑(f (r * s)))⁻¹) * ↑(f (r * s)) ∈ ↑(closure U) * R

Next tactic:
refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
    

Proof state:
case Hmul.intro.intro.intro.intro
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ r * s * (↑(f (r * s)))⁻¹ ∈ closure U

Next tactic:
exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
    exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
  · 

Proof state:
case Hinv
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
⊢ ∀ (x y : G), y ∈ S → x ∈ ↑(closure U) * R → x * y⁻¹ ∈ ↑(closure U) * R

Next tactic:
rintro - s hs ⟨u, r, hu, hr, rfl⟩
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
    exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    

Proof state:
case Hinv.intro.intro.intro.intro
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ (fun x x_1 => x * x_1) u r * s⁻¹ ∈ ↑(closure U) * R

Next tactic:
rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group]
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
    exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by 

Proof state:
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ u * r * s⁻¹ = u * (↑(f (r * s⁻¹)) * s * r⁻¹)⁻¹ * ↑(f (r * s⁻¹))

Next tactic:
group
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
    exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group]
    

Proof state:
case Hinv.intro.intro.intro.intro
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ u * (↑(f (r * s⁻¹)) * s * r⁻¹)⁻¹ * ↑(f (r * s⁻¹)) ∈ ↑(closure U) * R

Next tactic:
refine' Set.mul_mem_mul ((closure U).mul_mem hu ((closure U).inv_mem _)) (f (r * s⁻¹)).2
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
    exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu ((closure U).inv_mem _)) (f (r * s⁻¹)).2
    

Proof state:
case Hinv.intro.intro.intro.intro
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ ↑(f (r * s⁻¹)) * s * r⁻¹ ∈ closure U

Next tactic:
refine' subset_closure ⟨f (r * s⁻¹) * s, Set.mul_mem_mul (f (r * s⁻¹)).2 hs, _⟩
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
    exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu ((closure U).inv_mem _)) (f (r * s⁻¹)).2
    refine' subset_closure ⟨f (r * s⁻¹) * s, Set.mul_mem_mul (f (r * s⁻¹)).2 hs, _⟩
    

Proof state:
case Hinv.intro.intro.intro.intro
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ (fun g => g * (↑(f g))⁻¹) (↑(f (r * s⁻¹)) * s) = ↑(f (r * s⁻¹)) * s * r⁻¹

Next tactic:
rw [mul_right_inj, inv_inj, ← Subtype.coe_mk r hr, ← Subtype.ext_iff, Subtype.coe_mk]
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
    exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu ((closure U).inv_mem _)) (f (r * s⁻¹)).2
    refine' subset_closure ⟨f (r * s⁻¹) * s, Set.mul_mem_mul (f (r * s⁻¹)).2 hs, _⟩
    rw [mul_right_inj, inv_inj, ← Subtype.coe_mk r hr, ← Subtype.ext_iff, Subtype.coe_mk]
    

Proof state:
case Hinv.intro.intro.intro.intro
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ f (↑(toFun hR (↑{ val := r, property := hr } * s⁻¹)) * s) = { val := r, property := hr }

Next tactic:
apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.mp hR (f (r * s⁻¹) * s)).unique
      (mul_inv_toFun_mem hR (f (r * s⁻¹) * s))
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
    exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu ((closure U).inv_mem _)) (f (r * s⁻¹)).2
    refine' subset_closure ⟨f (r * s⁻¹) * s, Set.mul_mem_mul (f (r * s⁻¹)).2 hs, _⟩
    rw [mul_right_inj, inv_inj, ← Subtype.coe_mk r hr, ← Subtype.ext_iff, Subtype.coe_mk]
    apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.mp hR (f (r * s⁻¹) * s)).unique
      (mul_inv_toFun_mem hR (f (r * s⁻¹) * s))
    

Proof state:
case Hinv.intro.intro.intro.intro
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ ↑(f (r * s⁻¹)) * s * (↑{ val := r, property := hr })⁻¹ ∈ ↑H

Next tactic:
rw [mul_assoc, ← inv_inv s, ← mul_inv_rev, inv_inv]
theorem closure_mul_image_mul_eq_top
    (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
    (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
  let f : G → R := fun g => toFun hR g
  let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
  change (closure U : Set G) * R = ⊤
  refine' top_le_iff.mp fun g _ => _
  apply closure_induction_right (eq_top_iff.mp hS (mem_top g))
  · exact ⟨1, 1, (closure U).one_mem, hR1, one_mul 1⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu _) (f (r * s)).coe_prop
    exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
  · rintro - s hs ⟨u, r, hu, hr, rfl⟩
    rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group]
    refine' Set.mul_mem_mul ((closure U).mul_mem hu ((closure U).inv_mem _)) (f (r * s⁻¹)).2
    refine' subset_closure ⟨f (r * s⁻¹) * s, Set.mul_mem_mul (f (r * s⁻¹)).2 hs, _⟩
    rw [mul_right_inj, inv_inj, ← Subtype.coe_mk r hr, ← Subtype.ext_iff, Subtype.coe_mk]
    apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.mp hR (f (r * s⁻¹) * s)).unique
      (mul_inv_toFun_mem hR (f (r * s⁻¹) * s))
    rw [mul_assoc, ← inv_inv s, ← mul_inv_rev, inv_inv]
    

Proof state:
case Hinv.intro.intro.intro.intro
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
f : G → ↑R := fun g => toFun hR g
U : Set G := (fun g => g * (↑(f g))⁻¹) '' (R * S)
g : G
x✝ : g ∈ ⊤
s : G
hs : s ∈ S
u r : G
hu : u ∈ ↑(closure U)
hr : r ∈ R
⊢ ↑(f (r * s⁻¹)) * (↑{ val := r, property := hr } * s⁻¹)⁻¹ ∈ ↑H

Next tactic:
exact toFun_mul_inv_mem hR (r * s⁻¹)
/-- **Schreier's Lemma**: If `R : Set G` is a `rightTransversal of` `H : Subgroup G`
  with `1 ∈ R`, and if `G` is generated by `S : Set G`, then `H` is generated by the `Set`
  `(R * S).image (fun g ↦ g * (toFun hR g)⁻¹)`. -/
theorem closure_mul_image_eq (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R)
    (hS : closure S = ⊤) : closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹) = H := by
  

Proof state:
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
⊢ closure ((fun g => g * (↑(toFun hR g))⁻¹) '' (R * S)) = H

Next tactic:
have hU : closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹) ≤ H := by
    rw [closure_le]
    rintro - ⟨g, -, rfl⟩
    exact mul_inv_toFun_mem hR g
/-- **Schreier's Lemma**: If `R : Set G` is a `rightTransversal of` `H : Subgroup G`
  with `1 ∈ R`, and if `G` is generated by `S : Set G`, then `H` is generated by the `Set`
  `(R * S).image (fun g ↦ g * (toFun hR g)⁻¹)`. -/
theorem closure_mul_image_eq (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R)
    (hS : closure S = ⊤) : closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹) = H := by
  have hU : closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹) ≤ H := by
    

Proof state:
G : Type u_1
inst✝ : Group G
H : Subgroup G
R S : Set G
hR : R ∈ rightTransversals ↑H
hR1 : 1 ∈ R
hS : closure S = ⊤
⊢ closure ((fun g => g * (↑(toFun hR g))⁻¹) '' (R * S)) ≤ H

Next tactic:
rw [closure_le]