l3lab/ntp-mathlib huggingface dataset:
/-- If `f` and `g` have the same constant term and derivative, then they are equal.-/
theorem derivative.ext {R} [CommRing R] [NoZeroSMulDivisors ℕ R] {f g} (hD : d⁄dX R f = d⁄dX R g)
    (hc : constantCoeff R f = constantCoeff R g) : f = g := by
  ext n
  cases n with
  | zero =>
    rw [coeff_zero_eq_constantCoeff, hc]
  | succ n =>
    have equ : coeff R n (d⁄dX R f) = coeff R n (d⁄dX R g) := by rw [hD]
    

Proof state:
case h.succ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : NoZeroSMulDivisors ℕ R
f g : R⟦X⟧
hD : (d⁄dX R) f = (d⁄dX R) g
hc : (constantCoeff R) f = (constantCoeff R) g
n : ℕ
equ : (coeff R n) ((d⁄dX R) f) = (coeff R n) ((d⁄dX R) g)
⊢ (coeff R (succ n)) f = (coeff R (succ n)) g

Next tactic:
rwa [coeff_derivative, coeff_derivative, ← cast_succ, mul_comm, ← nsmul_eq_mul,
      mul_comm, ← nsmul_eq_mul, smul_right_inj n.succ_ne_zero] at equ
@[simp] theorem derivative_inv {R} [CommRing R] (f : R⟦X⟧ˣ) :
    d⁄dX R ↑f⁻¹ = -(↑f⁻¹ : R⟦X⟧) ^ 2 * d⁄dX R f := by
  

Proof state:
R : Type u_1
inst✝ : CommRing R
f : R⟦X⟧ˣ
⊢ (d⁄dX R) ↑f⁻¹ = -↑f⁻¹ ^ 2 * (d⁄dX R) ↑f

Next tactic:
apply Derivation.leibniz_of_mul_eq_one
@[simp] theorem derivative_inv {R} [CommRing R] (f : R⟦X⟧ˣ) :
    d⁄dX R ↑f⁻¹ = -(↑f⁻¹ : R⟦X⟧) ^ 2 * d⁄dX R f := by
  apply Derivation.leibniz_of_mul_eq_one
  

Proof state:
case h
R : Type u_1
inst✝ : CommRing R
f : R⟦X⟧ˣ
⊢ ↑f⁻¹ * ↑f = 1

Next tactic:
simp
@[simp] theorem derivative_invOf {R} [CommRing R] (f : R⟦X⟧) [Invertible f] :
    d⁄dX R ⅟f = - ⅟f ^ 2 * d⁄dX R f := by
  

Proof state:
R : Type u_1
inst✝¹ : CommRing R
f : R⟦X⟧
inst✝ : Invertible f
⊢ (d⁄dX R) ⅟f = -⅟f ^ 2 * (d⁄dX R) f

Next tactic:
rw [Derivation.leibniz_invOf, smul_eq_mul]
@[simp] theorem derivative_inv' {R} [Field R] (f : R⟦X⟧) : d⁄dX R f⁻¹ = -f⁻¹ ^ 2 * d⁄dX R f := by
  

Proof state:
R : Type u_1
inst✝ : Field R
f : R⟦X⟧
⊢ (d⁄dX R) f⁻¹ = -f⁻¹ ^ 2 * (d⁄dX R) f

Next tactic:
by_cases h : constantCoeff R f = 0
@[simp] theorem derivative_inv' {R} [Field R] (f : R⟦X⟧) : d⁄dX R f⁻¹ = -f⁻¹ ^ 2 * d⁄dX R f := by
  by_cases h : constantCoeff R f = 0
  · 

Proof state:
case pos
R : Type u_1
inst✝ : Field R
f : R⟦X⟧
h : (constantCoeff R) f = 0
⊢ (d⁄dX R) f⁻¹ = -f⁻¹ ^ 2 * (d⁄dX R) f

Next tactic:
suffices f⁻¹ = 0 by
      rw [this, pow_two, zero_mul, neg_zero, zero_mul, map_zero]
@[simp] theorem derivative_inv' {R} [Field R] (f : R⟦X⟧) : d⁄dX R f⁻¹ = -f⁻¹ ^ 2 * d⁄dX R f := by
  by_cases h : constantCoeff R f = 0
  · suffices f⁻¹ = 0 by
      

Proof state:
R : Type u_1
inst✝ : Field R
f : R⟦X⟧
h : (constantCoeff R) f = 0
this : f⁻¹ = 0
⊢ (d⁄dX R) f⁻¹ = -f⁻¹ ^ 2 * (d⁄dX R) f

Next tactic:
rw [this, pow_two, zero_mul, neg_zero, zero_mul, map_zero]
@[simp] theorem derivative_inv' {R} [Field R] (f : R⟦X⟧) : d⁄dX R f⁻¹ = -f⁻¹ ^ 2 * d⁄dX R f := by
  by_cases h : constantCoeff R f = 0
  · suffices f⁻¹ = 0 by
      rw [this, pow_two, zero_mul, neg_zero, zero_mul, map_zero]
    

Proof state:
case pos
R : Type u_1
inst✝ : Field R
f : R⟦X⟧
h : (constantCoeff R) f = 0
⊢ f⁻¹ = 0

Next tactic:
rwa [MvPowerSeries.inv_eq_zero]
@[simp] theorem derivative_inv' {R} [Field R] (f : R⟦X⟧) : d⁄dX R f⁻¹ = -f⁻¹ ^ 2 * d⁄dX R f := by
  by_cases h : constantCoeff R f = 0
  · suffices f⁻¹ = 0 by
      rw [this, pow_two, zero_mul, neg_zero, zero_mul, map_zero]
    rwa [MvPowerSeries.inv_eq_zero]
  

Proof state:
case neg
R : Type u_1
inst✝ : Field R
f : R⟦X⟧
h : ¬(constantCoeff R) f = 0
⊢ (d⁄dX R) f⁻¹ = -f⁻¹ ^ 2 * (d⁄dX R) f

Next tactic:
apply Derivation.leibniz_of_mul_eq_one
@[simp] theorem derivative_inv' {R} [Field R] (f : R⟦X⟧) : d⁄dX R f⁻¹ = -f⁻¹ ^ 2 * d⁄dX R f := by
  by_cases h : constantCoeff R f = 0
  · suffices f⁻¹ = 0 by
      rw [this, pow_two, zero_mul, neg_zero, zero_mul, map_zero]
    rwa [MvPowerSeries.inv_eq_zero]
  apply Derivation.leibniz_of_mul_eq_one
  

Proof state:
case neg.h
R : Type u_1
inst✝ : Field R
f : R⟦X⟧
h : ¬(constantCoeff R) f = 0
⊢ f⁻¹ * f = 1

Next tactic:
exact PowerSeries.inv_mul_cancel (h := h)
/-- The commutator of derivations is again a derivation. -/
instance : Bracket (Derivation R A A) (Derivation R A A) :=
  ⟨fun D1 D2 =>
    mk' ⁅(D1 : Module.End R A), (D2 : Module.End R A)⁆ fun a b => by
      

Proof state:
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1✝ D2✝ : Derivation R A A
a✝ : A
D1 D2 : Derivation R A A
a b : A
⊢ ⁅↑D1, ↑D2⁆ (a * b) = a • ⁅↑D1, ↑D2⁆ b + b • ⁅↑D1, ↑D2⁆ a

Next tactic:
simp only [Ring.lie_def, map_add, Algebra.id.smul_eq_mul, LinearMap.mul_apply, leibniz,
        coeFn_coe, LinearMap.sub_apply]
/-- The commutator of derivations is again a derivation. -/
instance : Bracket (Derivation R A A) (Derivation R A A) :=
  ⟨fun D1 D2 =>
    mk' ⁅(D1 : Module.End R A), (D2 : Module.End R A)⁆ fun a b => by
      simp only [Ring.lie_def, map_add, Algebra.id.smul_eq_mul, LinearMap.mul_apply, leibniz,
        coeFn_coe, LinearMap.sub_apply]
      

Proof state:
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1✝ D2✝ : Derivation R A A
a✝ : A
D1 D2 : Derivation R A A
a b : A
⊢ a * D1 (D2 b) + D2 b * D1 a + (b * D1 (D2 a) + D2 a * D1 b) -
      (a * D2 (D1 b) + D1 b * D2 a + (b * D2 (D1 a) + D1 a * D2 b)) =
    a * (D1 (D2 b) - D2 (D1 b)) + b * (D1 (D2 a) - D2 (D1 a))

Next tactic:
ring
instance : LieRing (Derivation R A A) where
  add_lie d e f := by 

Proof state:
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a : A
d e f : Derivation R A A
⊢ ⁅d + e, f⁆ = ⁅d, f⁆ + ⁅e, f⁆

Next tactic:
ext a
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; 

Proof state:
case H
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a✝ : A
d e f : Derivation R A A
a : A
⊢ ⁅d + e, f⁆ a = (⁅d, f⁆ + ⁅e, f⁆) a

Next tactic:
simp only [commutator_apply, add_apply, map_add]
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; 

Proof state:
case H
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a✝ : A
d e f : Derivation R A A
a : A
⊢ d (f a) + e (f a) - (f (d a) + f (e a)) = d (f a) - f (d a) + (e (f a) - f (e a))

Next tactic:
ring
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_add d e f := by 

Proof state:
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a : A
d e f : Derivation R A A
⊢ ⁅d, e + f⁆ = ⁅d, e⁆ + ⁅d, f⁆

Next tactic:
ext a
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_add d e f := by ext a; 

Proof state:
case H
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a✝ : A
d e f : Derivation R A A
a : A
⊢ ⁅d, e + f⁆ a = (⁅d, e⁆ + ⁅d, f⁆) a

Next tactic:
simp only [commutator_apply, add_apply, map_add]
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_add d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; 

Proof state:
case H
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a✝ : A
d e f : Derivation R A A
a : A
⊢ d (e a) + d (f a) - (e (d a) + f (d a)) = d (e a) - e (d a) + (d (f a) - f (d a))

Next tactic:
ring
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_add d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_self d := by 

Proof state:
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a : A
d : Derivation R A A
⊢ ⁅d, d⁆ = 0

Next tactic:
ext a
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_add d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_self d := by ext a; 

Proof state:
case H
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a✝ : A
d : Derivation R A A
a : A
⊢ ⁅d, d⁆ a = 0 a

Next tactic:
simp only [commutator_apply, add_apply, map_add]
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_add d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_self d := by ext a; simp only [commutator_apply, add_apply, map_add]; 

Proof state:
case H
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a✝ : A
d : Derivation R A A
a : A
⊢ d (d a) - d (d a) = 0 a

Next tactic:
ring_nf
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_add d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_self d := by ext a; simp only [commutator_apply, add_apply, map_add]; ring_nf; 

Proof state:
case H
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a✝ : A
d : Derivation R A A
a : A
⊢ 0 = 0 a

Next tactic:
simp
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_add d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_self d := by ext a; simp only [commutator_apply, add_apply, map_add]; ring_nf; simp
  leibniz_lie d e f := by 

Proof state:
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a : A
d e f : Derivation R A A
⊢ ⁅d, ⁅e, f⁆⁆ = ⁅⁅d, e⁆, f⁆ + ⁅e, ⁅d, f⁆⁆

Next tactic:
ext a
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_add d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_self d := by ext a; simp only [commutator_apply, add_apply, map_add]; ring_nf; simp
  leibniz_lie d e f := by ext a; 

Proof state:
case H
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a✝ : A
d e f : Derivation R A A
a : A
⊢ ⁅d, ⁅e, f⁆⁆ a = (⁅⁅d, e⁆, f⁆ + ⁅e, ⁅d, f⁆⁆) a

Next tactic:
simp only [commutator_apply, add_apply, sub_apply, map_sub]
instance : LieRing (Derivation R A A) where
  add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_add d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; ring
  lie_self d := by ext a; simp only [commutator_apply, add_apply, map_add]; ring_nf; simp
  leibniz_lie d e f := by ext a; simp only [commutator_apply, add_apply, sub_apply, map_sub]; 

Proof state:
case H
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a✝ : A
d e f : Derivation R A A
a : A
⊢ d (e (f a)) - d (f (e a)) - (e (f (d a)) - f (e (d a))) =
    d (e (f a)) - e (d (f a)) - (f (d (e a)) - f (e (d a))) + (e (d (f a)) - e (f (d a)) - (d (f (e a)) - f (d (e a))))

Next tactic:
ring
instance instLieAlgebra : LieAlgebra R (Derivation R A A) :=
  { Derivation.instModule with
    lie_smul := fun r d e => by
      

Proof state:
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a : A
src✝ : Module R (Derivation R A A) := instModule
r : R
d e : Derivation R A A
⊢ ⁅d, r • e⁆ = r • ⁅d, e⁆

Next tactic:
ext a
instance instLieAlgebra : LieAlgebra R (Derivation R A A) :=
  { Derivation.instModule with
    lie_smul := fun r d e => by
      ext a; 

Proof state:
case H
R : Type u_1
inst✝² : CommRing R
A : Type u_2
inst✝¹ : CommRing A
inst✝ : Algebra R A
D D1 D2 : Derivation R A A
a✝ : A
src✝ : Module R (Derivation R A A) := instModule
r : R
d e : Derivation R A A
a : A
⊢ ⁅d, r • e⁆ a = (r • ⁅d, e⁆) a

Next tactic:
simp only [commutator_apply, map_smul, smul_sub, smul_apply]
@[simp]
theorem map_id_comp (F : C × D ⥤ E) (W : C) {X Y Z : D} (f : X ⟶ Y) (g : Y ⟶ Z) :
    F.map ((𝟙 W, f ≫ g) : (W, X) ⟶ (W, Z)) =
      F.map ((𝟙 W, f) : (W, X) ⟶ (W, Y)) ≫ F.map ((𝟙 W, g) : (W, Y) ⟶ (W, Z)) := by
  

Proof state:
C : Type u₁
D : Type u₂
E : Type u₃
inst✝² : Category.{v₁, u₁} C
inst✝¹ : Category.{v₂, u₂} D
inst✝ : Category.{v₃, u₃} E
F : C × D ⥤ E
W : C
X Y Z : D
f : X ⟶ Y
g : Y ⟶ Z
⊢ F.map (𝟙 W, f ≫ g) = F.map (𝟙 W, f) ≫ F.map (𝟙 W, g)

Next tactic:
rw [← Functor.map_comp, prod_comp, Category.comp_id]
@[simp]
theorem map_comp_id (F : C × D ⥤ E) (X Y Z : C) (W : D) (f : X ⟶ Y) (g : Y ⟶ Z) :
    F.map ((f ≫ g, 𝟙 W) : (X, W) ⟶ (Z, W)) =
      F.map ((f, 𝟙 W) : (X, W) ⟶ (Y, W)) ≫ F.map ((g, 𝟙 W) : (Y, W) ⟶ (Z, W)) := by
  

Proof state:
C : Type u₁
D : Type u₂
E : Type u₃
inst✝² : Category.{v₁, u₁} C
inst✝¹ : Category.{v₂, u₂} D
inst✝ : Category.{v₃, u₃} E
F : C × D ⥤ E
X Y Z : C
W : D
f : X ⟶ Y
g : Y ⟶ Z
⊢ F.map (f ≫ g, 𝟙 W) = F.map (f, 𝟙 W) ≫ F.map (g, 𝟙 W)

Next tactic:
rw [← Functor.map_comp, prod_comp, Category.comp_id]
@[simp]
theorem diagonal (F : C × D ⥤ E) (X X' : C) (f : X ⟶ X') (Y Y' : D) (g : Y ⟶ Y') :
    F.map ((𝟙 X, g) : (X, Y) ⟶ (X, Y')) ≫ F.map ((f, 𝟙 Y') : (X, Y') ⟶ (X', Y')) =
      F.map ((f, g) : (X, Y) ⟶ (X', Y')) := by
  

Proof state:
C : Type u₁
D : Type u₂
E : Type u₃
inst✝² : Category.{v₁, u₁} C
inst✝¹ : Category.{v₂, u₂} D
inst✝ : Category.{v₃, u₃} E
F : C × D ⥤ E
X X' : C
f : X ⟶ X'
Y Y' : D
g : Y ⟶ Y'
⊢ F.map (𝟙 X, g) ≫ F.map (f, 𝟙 Y') = F.map (f, g)

Next tactic:
rw [← Functor.map_comp, prod_comp, Category.id_comp, Category.comp_id]
@[simp]
theorem diagonal' (F : C × D ⥤ E) (X X' : C) (f : X ⟶ X') (Y Y' : D) (g : Y ⟶ Y') :
    F.map ((f, 𝟙 Y) : (X, Y) ⟶ (X', Y)) ≫ F.map ((𝟙 X', g) : (X', Y) ⟶ (X', Y')) =
      F.map ((f, g) : (X, Y) ⟶ (X', Y')) := by
  

Proof state:
C : Type u₁
D : Type u₂
E : Type u₃
inst✝² : Category.{v₁, u₁} C
inst✝¹ : Category.{v₂, u₂} D
inst✝ : Category.{v₃, u₃} E
F : C × D ⥤ E
X X' : C
f : X ⟶ X'
Y Y' : D
g : Y ⟶ Y'
⊢ F.map (f, 𝟙 Y) ≫ F.map (𝟙 X', g) = F.map (f, g)

Next tactic:
rw [← Functor.map_comp, prod_comp, Category.id_comp, Category.comp_id]
@[ext]
theorem ext {P Q : Sylow p G} (h : (P : Subgroup G) = Q) : P = Q := by 

Proof state:
p : ℕ
G : Type u_1
inst✝ : Group G
P Q : Sylow p G
h : ↑P = ↑Q
⊢ P = Q

Next tactic:
cases P
@[ext]
theorem ext {P Q : Sylow p G} (h : (P : Subgroup G) = Q) : P = Q := by cases P; 

Proof state:
case mk
p : ℕ
G : Type u_1
inst✝ : Group G
Q : Sylow p G
toSubgroup✝ : Subgroup G
isPGroup'✝ : IsPGroup p ↥toSubgroup✝
is_maximal'✝ : ∀ {Q : Subgroup G}, IsPGroup p ↥Q → toSubgroup✝ ≤ Q → Q = toSubgroup✝
h : ↑{ toSubgroup := toSubgroup✝, isPGroup' := isPGroup'✝, is_maximal' := is_maximal'✝ } = ↑Q
⊢ { toSubgroup := toSubgroup✝, isPGroup' := isPGroup'✝, is_maximal' := is_maximal'✝ } = Q

Next tactic:
cases Q
@[ext]
theorem ext {P Q : Sylow p G} (h : (P : Subgroup G) = Q) : P = Q := by cases P; cases Q; 

Proof state:
case mk.mk
p : ℕ
G : Type u_1
inst✝ : Group G
toSubgroup✝¹ : Subgroup G
isPGroup'✝¹ : IsPGroup p ↥toSubgroup✝¹
is_maximal'✝¹ : ∀ {Q : Subgroup G}, IsPGroup p ↥Q → toSubgroup✝¹ ≤ Q → Q = toSubgroup✝¹
toSubgroup✝ : Subgroup G
isPGroup'✝ : IsPGroup p ↥toSubgroup✝
is_maximal'✝ : ∀ {Q : Subgroup G}, IsPGroup p ↥Q → toSubgroup✝ ≤ Q → Q = toSubgroup✝
h :
  ↑{ toSubgroup := toSubgroup✝¹, isPGroup' := isPGroup'✝¹, is_maximal' := is_maximal'✝¹ } =
    ↑{ toSubgroup := toSubgroup✝, isPGroup' := isPGroup'✝, is_maximal' := is_maximal'✝ }
⊢ { toSubgroup := toSubgroup✝¹, isPGroup' := isPGroup'✝¹, is_maximal' := is_maximal'✝¹ } =
    { toSubgroup := toSubgroup✝, isPGroup' := isPGroup'✝, is_maximal' := is_maximal'✝ }

Next tactic:
congr
/-- The preimage of a Sylow subgroup under a p-group-kernel homomorphism is a Sylow subgroup. -/
def comapOfKerIsPGroup (hϕ : IsPGroup p ϕ.ker) (h : ↑P ≤ ϕ.range) : Sylow p K :=
  { P.1.comap ϕ with
    isPGroup' := P.2.comap_of_ker_isPGroup ϕ hϕ
    is_maximal' := fun {Q} hQ hle => by
      

Proof state:
p : ℕ
G : Type u_1
inst✝¹ : Group G
P : Sylow p G
K : Type u_2
inst✝ : Group K
ϕ : K →* G
N : Subgroup G
hϕ : IsPGroup p ↥(MonoidHom.ker ϕ)
h : ↑P ≤ MonoidHom.range ϕ
src✝ : Subgroup K := comap ϕ ↑P
Q : Subgroup K
hQ : IsPGroup p ↥Q
hle : { toSubmonoid := src✝.toSubmonoid, inv_mem' := (_ : ∀ {x : K}, x ∈ src✝.carrier → x⁻¹ ∈ src✝.carrier) } ≤ Q
⊢ Q = { toSubmonoid := src✝.toSubmonoid, inv_mem' := (_ : ∀ {x : K}, x ∈ src✝.carrier → x⁻¹ ∈ src✝.carrier) }

Next tactic:
show Q = P.1.comap ϕ
/-- The preimage of a Sylow subgroup under a p-group-kernel homomorphism is a Sylow subgroup. -/
def comapOfKerIsPGroup (hϕ : IsPGroup p ϕ.ker) (h : ↑P ≤ ϕ.range) : Sylow p K :=
  { P.1.comap ϕ with
    isPGroup' := P.2.comap_of_ker_isPGroup ϕ hϕ
    is_maximal' := fun {Q} hQ hle => by
      show Q = P.1.comap ϕ
      

Proof state:
p : ℕ
G : Type u_1
inst✝¹ : Group G
P : Sylow p G
K : Type u_2
inst✝ : Group K
ϕ : K →* G
N : Subgroup G
hϕ : IsPGroup p ↥(MonoidHom.ker ϕ)
h : ↑P ≤ MonoidHom.range ϕ
src✝ : Subgroup K := comap ϕ ↑P
Q : Subgroup K
hQ : IsPGroup p ↥Q
hle : { toSubmonoid := src✝.toSubmonoid, inv_mem' := (_ : ∀ {x : K}, x ∈ src✝.carrier → x⁻¹ ∈ src✝.carrier) } ≤ Q
⊢ Q = comap ϕ ↑P

Next tactic:
rw [← P.3 (hQ.map ϕ) (le_trans (ge_of_eq (map_comap_eq_self h)) (map_mono hle))]
/-- The preimage of a Sylow subgroup under a p-group-kernel homomorphism is a Sylow subgroup. -/
def comapOfKerIsPGroup (hϕ : IsPGroup p ϕ.ker) (h : ↑P ≤ ϕ.range) : Sylow p K :=
  { P.1.comap ϕ with
    isPGroup' := P.2.comap_of_ker_isPGroup ϕ hϕ
    is_maximal' := fun {Q} hQ hle => by
      show Q = P.1.comap ϕ
      rw [← P.3 (hQ.map ϕ) (le_trans (ge_of_eq (map_comap_eq_self h)) (map_mono hle))]
      

Proof state:
p : ℕ
G : Type u_1
inst✝¹ : Group G
P : Sylow p G
K : Type u_2
inst✝ : Group K
ϕ : K →* G
N : Subgroup G
hϕ : IsPGroup p ↥(MonoidHom.ker ϕ)
h : ↑P ≤ MonoidHom.range ϕ
src✝ : Subgroup K := comap ϕ ↑P
Q : Subgroup K
hQ : IsPGroup p ↥Q
hle : { toSubmonoid := src✝.toSubmonoid, inv_mem' := (_ : ∀ {x : K}, x ∈ src✝.carrier → x⁻¹ ∈ src✝.carrier) } ≤ Q
⊢ Q = comap ϕ (map ϕ Q)

Next tactic:
exact (comap_map_eq_self ((P.1.ker_le_comap ϕ).trans hle)).symm
/-- A sylow subgroup of G is also a sylow subgroup of a subgroup of G. -/
protected def subtype (h : ↑P ≤ N) : Sylow p N :=
  P.comapOfInjective N.subtype Subtype.coe_injective (by 

Proof state:
p : ℕ
G : Type u_1
inst✝¹ : Group G
P : Sylow p G
K : Type u_2
inst✝ : Group K
ϕ : K →* G
N : Subgroup G
h : ↑P ≤ N
⊢ ↑P ≤ MonoidHom.range (Subgroup.subtype N)

Next tactic:
rwa [subtype_range]
theorem subtype_injective {P Q : Sylow p G} {hP : ↑P ≤ N} {hQ : ↑Q ≤ N}
    (h : P.subtype hP = Q.subtype hQ) : P = Q := by
  

Proof state:
p : ℕ
G : Type u_1
inst✝¹ : Group G
P✝ : Sylow p G
K : Type u_2
inst✝ : Group K
ϕ : K →* G
N : Subgroup G
P Q : Sylow p G
hP : ↑P ≤ N
hQ : ↑Q ≤ N
h : Sylow.subtype P hP = Sylow.subtype Q hQ
⊢ P = Q

Next tactic:
rw [SetLike.ext_iff] at h ⊢
theorem subtype_injective {P Q : Sylow p G} {hP : ↑P ≤ N} {hQ : ↑Q ≤ N}
    (h : P.subtype hP = Q.subtype hQ) : P = Q := by
  rw [SetLike.ext_iff] at h ⊢
  

Proof state:
p : ℕ
G : Type u_1
inst✝¹ : Group G
P✝ : Sylow p G
K : Type u_2
inst✝ : Group K
ϕ : K →* G
N : Subgroup G
P Q : Sylow p G
hP : ↑P ≤ N
hQ : ↑Q ≤ N
h : ∀ (x : ↥N), x ∈ Sylow.subtype P hP ↔ x ∈ Sylow.subtype Q hQ
⊢ ∀ (x : G), x ∈ P ↔ x ∈ Q

Next tactic:
exact fun g => ⟨fun hg => (h ⟨g, hP hg⟩).mp hg, fun hg => (h ⟨g, hQ hg⟩).mpr hg⟩
/-- A generalization of **Sylow's first theorem**.
  Every `p`-subgroup is contained in a Sylow `p`-subgroup. -/
theorem IsPGroup.exists_le_sylow {P : Subgroup G} (hP : IsPGroup p P) : ∃ Q : Sylow p G, P ≤ Q :=
  Exists.elim
    (zorn_nonempty_partialOrder₀ { Q : Subgroup G | IsPGroup p Q }
      (fun c hc1 hc2 Q hQ =>
        ⟨{  carrier := ⋃ R : c, R
            one_mem' := ⟨Q, ⟨⟨Q, hQ⟩, rfl⟩, Q.one_mem⟩
            inv_mem' := fun {g} ⟨_, ⟨R, rfl⟩, hg⟩ => ⟨R, ⟨R, rfl⟩, R.1.inv_mem hg⟩
            mul_mem' := fun {g} h ⟨_, ⟨R, rfl⟩, hg⟩ ⟨_, ⟨S, rfl⟩, hh⟩ =>
              (hc2.total R.2 S.2).elim (fun T => ⟨S, ⟨S, rfl⟩, S.1.mul_mem (T hg) hh⟩) fun T =>
                ⟨R, ⟨R, rfl⟩, R.1.mul_mem hg (T hh)⟩ },
          fun ⟨g, _, ⟨S, rfl⟩, hg⟩ => by
          

Proof state:
p : ℕ
G : Type u_1
inst✝ : Group G
P : Subgroup G
hP : IsPGroup p ↥P
c : Set (Subgroup G)
hc1 : c ⊆ {Q | IsPGroup p ↥Q}
hc2 : IsChain (fun x x_1 => x ≤ x_1) c
Q : Subgroup G
hQ : Q ∈ c
x✝ :
  ↥{
      toSubmonoid :=
        {
          toSubsemigroup :=
            { carrier := ⋃ R, ↑↑R,
              mul_mem' := (_ : ∀ {g : G} (h : G), g ∈ ⋃ R, ↑↑R → h ∈ ⋃ R, ↑↑R → g * h ∈ ⋃ R, ↑↑R) },
          one_mem' := (_ : ∃ t ∈ Set.range fun R => ↑↑R, 1 ∈ t) },
      inv_mem' :=
        (_ :
          ∀ {g : G},
            g ∈
                {
                      toSubsemigroup :=
                        { carrier := ⋃ R, ↑↑R,
                          mul_mem' := (_ : ∀ {g : G} (h : G), g ∈ ⋃ R, ↑↑R → h ∈ ⋃ R, ↑↑R → g * h ∈ ⋃ R, ↑↑R) },
                      one_mem' := (_ : ∃ t ∈ Set.range fun R => ↑↑R, 1 ∈ t) }.toSubsemigroup.carrier →
              g⁻¹ ∈
                {
                      toSubsemigroup :=
                        { carrier := ⋃ R, ↑↑R,
                          mul_mem' := (_ : ∀ {g : G} (h : G), g ∈ ⋃ R, ↑↑R → h ∈ ⋃ R, ↑↑R → g * h ∈ ⋃ R, ↑↑R) },
                      one_mem' := (_ : ∃ t ∈ Set.range fun R => ↑↑R, 1 ∈ t) }.toSubsemigroup.carrier) }
g : G
S : ↑c
hg : g ∈ (fun R => ↑↑R) S
⊢ ∃ k, { val := g, property := (_ : ∃ t ∈ Set.range fun R => ↑↑R, g ∈ t) } ^ p ^ k = 1

Next tactic:
refine' Exists.imp (fun k hk => _) (hc1 S.2 ⟨g, hg⟩)
/-- A generalization of **Sylow's first theorem**.
  Every `p`-subgroup is contained in a Sylow `p`-subgroup. -/
theorem IsPGroup.exists_le_sylow {P : Subgroup G} (hP : IsPGroup p P) : ∃ Q : Sylow p G, P ≤ Q :=
  Exists.elim
    (zorn_nonempty_partialOrder₀ { Q : Subgroup G | IsPGroup p Q }
      (fun c hc1 hc2 Q hQ =>
        ⟨{  carrier := ⋃ R : c, R
            one_mem' := ⟨Q, ⟨⟨Q, hQ⟩, rfl⟩, Q.one_mem⟩
            inv_mem' := fun {g} ⟨_, ⟨R, rfl⟩, hg⟩ => ⟨R, ⟨R, rfl⟩, R.1.inv_mem hg⟩
            mul_mem' := fun {g} h ⟨_, ⟨R, rfl⟩, hg⟩ ⟨_, ⟨S, rfl⟩, hh⟩ =>
              (hc2.total R.2 S.2).elim (fun T => ⟨S, ⟨S, rfl⟩, S.1.mul_mem (T hg) hh⟩) fun T =>
                ⟨R, ⟨R, rfl⟩, R.1.mul_mem hg (T hh)⟩ },
          fun ⟨g, _, ⟨S, rfl⟩, hg⟩ => by
          refine' Exists.imp (fun k hk => _) (hc1 S.2 ⟨g, hg⟩)
          

Proof state:
p : ℕ
G : Type u_1
inst✝ : Group G
P : Subgroup G
hP : IsPGroup p ↥P
c : Set (Subgroup G)
hc1 : c ⊆ {Q | IsPGroup p ↥Q}
hc2 : IsChain (fun x x_1 => x ≤ x_1) c
Q : Subgroup G
hQ : Q ∈ c
x✝ :
  ↥{
      toSubmonoid :=
        {
          toSubsemigroup :=
            { carrier := ⋃ R, ↑↑R,
              mul_mem' := (_ : ∀ {g : G} (h : G), g ∈ ⋃ R, ↑↑R → h ∈ ⋃ R, ↑↑R → g * h ∈ ⋃ R, ↑↑R) },
          one_mem' := (_ : ∃ t ∈ Set.range fun R => ↑↑R, 1 ∈ t) },
      inv_mem' :=
        (_ :
          ∀ {g : G},
            g ∈
                {
                      toSubsemigroup :=
                        { carrier := ⋃ R, ↑↑R,
                          mul_mem' := (_ : ∀ {g : G} (h : G), g ∈ ⋃ R, ↑↑R → h ∈ ⋃ R, ↑↑R → g * h ∈ ⋃ R, ↑↑R) },
                      one_mem' := (_ : ∃ t ∈ Set.range fun R => ↑↑R, 1 ∈ t) }.toSubsemigroup.carrier →
              g⁻¹ ∈
                {
                      toSubsemigroup :=
                        { carrier := ⋃ R, ↑↑R,
                          mul_mem' := (_ : ∀ {g : G} (h : G), g ∈ ⋃ R, ↑↑R → h ∈ ⋃ R, ↑↑R → g * h ∈ ⋃ R, ↑↑R) },
                      one_mem' := (_ : ∃ t ∈ Set.range fun R => ↑↑R, 1 ∈ t) }.toSubsemigroup.carrier) }
g : G
S : ↑c
hg : g ∈ (fun R => ↑↑R) S
k : ℕ
hk : { val := g, property := hg } ^ p ^ k = 1
⊢ { val := g, property := (_ : ∃ t ∈ Set.range fun R => ↑↑R, g ∈ t) } ^ p ^ k = 1

Next tactic:
rwa [Subtype.ext_iff, coe_pow] at hk ⊢