l3lab/ntp-mathlib huggingface dataset:
theorem Subalgebra.inv_mem_of_algebraic {x : A} (hx : _root_.IsAlgebraic K (x : L)) :
    (x⁻¹ : L) ∈ A := by
  obtain ⟨p, ne_zero, aeval_eq⟩ := hx
  rw [Subalgebra.aeval_coe, Subalgebra.coe_eq_zero] at aeval_eq
  revert ne_zero aeval_eq
  refine' p.recOnHorner _ _ _
  · intro h
    contradiction
  · intro p a hp ha _ih _ne_zero aeval_eq
    refine' A.inv_mem_of_root_of_coeff_zero_ne_zero aeval_eq _
    rwa [coeff_add, hp, zero_add, coeff_C, if_pos rfl]
  · intro p hp ih _ne_zero aeval_eq
    rw [AlgHom.map_mul, aeval_X, mul_eq_zero] at aeval_eq
    

Proof state:
case intro.intro.refine'_3
R : Type u_1
S : Type u_2
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : CommRing S
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
A : Subalgebra K L
x : ↥A
p✝ p : K[X]
hp : p ≠ 0
ih : p ≠ 0 → (aeval x) p = 0 → (↑x)⁻¹ ∈ A
_ne_zero : p * X ≠ 0
aeval_eq : (aeval x) p = 0 ∨ x = 0
⊢ (↑x)⁻¹ ∈ A

Next tactic:
cases' aeval_eq with aeval_eq x_eq
theorem Subalgebra.inv_mem_of_algebraic {x : A} (hx : _root_.IsAlgebraic K (x : L)) :
    (x⁻¹ : L) ∈ A := by
  obtain ⟨p, ne_zero, aeval_eq⟩ := hx
  rw [Subalgebra.aeval_coe, Subalgebra.coe_eq_zero] at aeval_eq
  revert ne_zero aeval_eq
  refine' p.recOnHorner _ _ _
  · intro h
    contradiction
  · intro p a hp ha _ih _ne_zero aeval_eq
    refine' A.inv_mem_of_root_of_coeff_zero_ne_zero aeval_eq _
    rwa [coeff_add, hp, zero_add, coeff_C, if_pos rfl]
  · intro p hp ih _ne_zero aeval_eq
    rw [AlgHom.map_mul, aeval_X, mul_eq_zero] at aeval_eq
    cases' aeval_eq with aeval_eq x_eq
    · 

Proof state:
case intro.intro.refine'_3.inl
R : Type u_1
S : Type u_2
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : CommRing S
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
A : Subalgebra K L
x : ↥A
p✝ p : K[X]
hp : p ≠ 0
ih : p ≠ 0 → (aeval x) p = 0 → (↑x)⁻¹ ∈ A
_ne_zero : p * X ≠ 0
aeval_eq : (aeval x) p = 0
⊢ (↑x)⁻¹ ∈ A

Next tactic:
exact ih hp aeval_eq
theorem Subalgebra.inv_mem_of_algebraic {x : A} (hx : _root_.IsAlgebraic K (x : L)) :
    (x⁻¹ : L) ∈ A := by
  obtain ⟨p, ne_zero, aeval_eq⟩ := hx
  rw [Subalgebra.aeval_coe, Subalgebra.coe_eq_zero] at aeval_eq
  revert ne_zero aeval_eq
  refine' p.recOnHorner _ _ _
  · intro h
    contradiction
  · intro p a hp ha _ih _ne_zero aeval_eq
    refine' A.inv_mem_of_root_of_coeff_zero_ne_zero aeval_eq _
    rwa [coeff_add, hp, zero_add, coeff_C, if_pos rfl]
  · intro p hp ih _ne_zero aeval_eq
    rw [AlgHom.map_mul, aeval_X, mul_eq_zero] at aeval_eq
    cases' aeval_eq with aeval_eq x_eq
    · exact ih hp aeval_eq
    · 

Proof state:
case intro.intro.refine'_3.inr
R : Type u_1
S : Type u_2
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : CommRing S
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
A : Subalgebra K L
x : ↥A
p✝ p : K[X]
hp : p ≠ 0
ih : p ≠ 0 → (aeval x) p = 0 → (↑x)⁻¹ ∈ A
_ne_zero : p * X ≠ 0
x_eq : x = 0
⊢ (↑x)⁻¹ ∈ A

Next tactic:
rw [x_eq, Subalgebra.coe_zero, inv_zero]
theorem Subalgebra.inv_mem_of_algebraic {x : A} (hx : _root_.IsAlgebraic K (x : L)) :
    (x⁻¹ : L) ∈ A := by
  obtain ⟨p, ne_zero, aeval_eq⟩ := hx
  rw [Subalgebra.aeval_coe, Subalgebra.coe_eq_zero] at aeval_eq
  revert ne_zero aeval_eq
  refine' p.recOnHorner _ _ _
  · intro h
    contradiction
  · intro p a hp ha _ih _ne_zero aeval_eq
    refine' A.inv_mem_of_root_of_coeff_zero_ne_zero aeval_eq _
    rwa [coeff_add, hp, zero_add, coeff_C, if_pos rfl]
  · intro p hp ih _ne_zero aeval_eq
    rw [AlgHom.map_mul, aeval_X, mul_eq_zero] at aeval_eq
    cases' aeval_eq with aeval_eq x_eq
    · exact ih hp aeval_eq
    · rw [x_eq, Subalgebra.coe_zero, inv_zero]
      

Proof state:
case intro.intro.refine'_3.inr
R : Type u_1
S : Type u_2
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : CommRing S
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
A : Subalgebra K L
x : ↥A
p✝ p : K[X]
hp : p ≠ 0
ih : p ≠ 0 → (aeval x) p = 0 → (↑x)⁻¹ ∈ A
_ne_zero : p * X ≠ 0
x_eq : x = 0
⊢ 0 ∈ A

Next tactic:
exact A.zero_mem
/-- In an algebraic extension L/K, an intermediate subalgebra is a field. -/
theorem Subalgebra.isField_of_algebraic (hKL : Algebra.IsAlgebraic K L) : IsField A :=
  { show Nontrivial A by 

Proof state:
R : Type u_1
S : Type u_2
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : CommRing S
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
A : Subalgebra K L
hKL : Algebra.IsAlgebraic K L
⊢ Nontrivial ↥A

Next tactic:
infer_instance
/-- This is not an instance for the same reasons as `Polynomial.hasSMulPi'`. -/
noncomputable def Polynomial.algebraPi : Algebra R'[X] (S' → T') :=
  { Polynomial.hasSMulPi' R' S' T' with
    toFun := fun p z => algebraMap S' T' (aeval z p)
    map_one' := by
      

Proof state:
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : IsDomain R
inst✝⁵ : CommRing S
R' : Type u
S' : Type v
T' : Type w
inst✝⁴ : CommSemiring R'
inst✝³ : CommSemiring S'
inst✝² : CommSemiring T'
inst✝¹ : Algebra R' S'
inst✝ : Algebra S' T'
src✝ : SMul R'[X] (S' → T') := hasSMulPi' R' S' T'
⊢ (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1

Next tactic:
funext z
/-- This is not an instance for the same reasons as `Polynomial.hasSMulPi'`. -/
noncomputable def Polynomial.algebraPi : Algebra R'[X] (S' → T') :=
  { Polynomial.hasSMulPi' R' S' T' with
    toFun := fun p z => algebraMap S' T' (aeval z p)
    map_one' := by
      funext z
      

Proof state:
case h
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : IsDomain R
inst✝⁵ : CommRing S
R' : Type u
S' : Type v
T' : Type w
inst✝⁴ : CommSemiring R'
inst✝³ : CommSemiring S'
inst✝² : CommSemiring T'
inst✝¹ : Algebra R' S'
inst✝ : Algebra S' T'
src✝ : SMul R'[X] (S' → T') := hasSMulPi' R' S' T'
z : S'
⊢ (fun p z => (algebraMap S' T') ((aeval z) p)) 1 z = OfNat.ofNat 1 z

Next tactic:
simp only [Polynomial.aeval_one, Pi.one_apply, map_one]
/-- This is not an instance for the same reasons as `Polynomial.hasSMulPi'`. -/
noncomputable def Polynomial.algebraPi : Algebra R'[X] (S' → T') :=
  { Polynomial.hasSMulPi' R' S' T' with
    toFun := fun p z => algebraMap S' T' (aeval z p)
    map_one' := by
      funext z
      simp only [Polynomial.aeval_one, Pi.one_apply, map_one]
    map_mul' := fun f g => by
      

Proof state:
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : IsDomain R
inst✝⁵ : CommRing S
R' : Type u
S' : Type v
T' : Type w
inst✝⁴ : CommSemiring R'
inst✝³ : CommSemiring S'
inst✝² : CommSemiring T'
inst✝¹ : Algebra R' S'
inst✝ : Algebra S' T'
src✝ : SMul R'[X] (S' → T') := hasSMulPi' R' S' T'
f g : R'[X]
⊢ OneHom.toFun
      { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
        map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
      (f * g) =
    OneHom.toFun
        { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
          map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
        f *
      OneHom.toFun
        { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
          map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
        g

Next tactic:
funext z
/-- This is not an instance for the same reasons as `Polynomial.hasSMulPi'`. -/
noncomputable def Polynomial.algebraPi : Algebra R'[X] (S' → T') :=
  { Polynomial.hasSMulPi' R' S' T' with
    toFun := fun p z => algebraMap S' T' (aeval z p)
    map_one' := by
      funext z
      simp only [Polynomial.aeval_one, Pi.one_apply, map_one]
    map_mul' := fun f g => by
      funext z
      

Proof state:
case h
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : IsDomain R
inst✝⁵ : CommRing S
R' : Type u
S' : Type v
T' : Type w
inst✝⁴ : CommSemiring R'
inst✝³ : CommSemiring S'
inst✝² : CommSemiring T'
inst✝¹ : Algebra R' S'
inst✝ : Algebra S' T'
src✝ : SMul R'[X] (S' → T') := hasSMulPi' R' S' T'
f g : R'[X]
z : S'
⊢ OneHom.toFun
      { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
        map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
      (f * g) z =
    (OneHom.toFun
          { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
            map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
          f *
        OneHom.toFun
          { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
            map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
          g)
      z

Next tactic:
simp only [Pi.mul_apply, map_mul]
/-- This is not an instance for the same reasons as `Polynomial.hasSMulPi'`. -/
noncomputable def Polynomial.algebraPi : Algebra R'[X] (S' → T') :=
  { Polynomial.hasSMulPi' R' S' T' with
    toFun := fun p z => algebraMap S' T' (aeval z p)
    map_one' := by
      funext z
      simp only [Polynomial.aeval_one, Pi.one_apply, map_one]
    map_mul' := fun f g => by
      funext z
      simp only [Pi.mul_apply, map_mul]
    map_zero' := by
      

Proof state:
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : IsDomain R
inst✝⁵ : CommRing S
R' : Type u
S' : Type v
T' : Type w
inst✝⁴ : CommSemiring R'
inst✝³ : CommSemiring S'
inst✝² : CommSemiring T'
inst✝¹ : Algebra R' S'
inst✝ : Algebra S' T'
src✝ : SMul R'[X] (S' → T') := hasSMulPi' R' S' T'
⊢ OneHom.toFun
      (↑{
          toOneHom :=
            { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
              map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) },
          map_mul' :=
            (_ :
              ∀ (f g : R'[X]),
                OneHom.toFun
                    { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
                      map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
                    (f * g) =
                  OneHom.toFun
                      { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
                        map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
                      f *
                    OneHom.toFun
                      { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
                        map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
                      g) })
      0 =
    0

Next tactic:
funext z
/-- This is not an instance for the same reasons as `Polynomial.hasSMulPi'`. -/
noncomputable def Polynomial.algebraPi : Algebra R'[X] (S' → T') :=
  { Polynomial.hasSMulPi' R' S' T' with
    toFun := fun p z => algebraMap S' T' (aeval z p)
    map_one' := by
      funext z
      simp only [Polynomial.aeval_one, Pi.one_apply, map_one]
    map_mul' := fun f g => by
      funext z
      simp only [Pi.mul_apply, map_mul]
    map_zero' := by
      funext z
      

Proof state:
case h
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : IsDomain R
inst✝⁵ : CommRing S
R' : Type u
S' : Type v
T' : Type w
inst✝⁴ : CommSemiring R'
inst✝³ : CommSemiring S'
inst✝² : CommSemiring T'
inst✝¹ : Algebra R' S'
inst✝ : Algebra S' T'
src✝ : SMul R'[X] (S' → T') := hasSMulPi' R' S' T'
z : S'
⊢ OneHom.toFun
      (↑{
          toOneHom :=
            { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
              map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) },
          map_mul' :=
            (_ :
              ∀ (f g : R'[X]),
                OneHom.toFun
                    { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
                      map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
                    (f * g) =
                  OneHom.toFun
                      { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
                        map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
                      f *
                    OneHom.toFun
                      { toFun := fun p z => (algebraMap S' T') ((aeval z) p),
                        map_one' := (_ : (fun p z => (algebraMap S' T') ((aeval z) p)) 1 = 1) }
                      g) })
      0 z =
    OfNat.ofNat 0 z

Next tactic:
simp only [Polynomial.aeval_zero, Pi.zero_apply, map_zero]
@[aesop norm -10 destruct (rule_sets [CategoryTheory])]
theorem hom_inl_inr_false {X : C} {Y : D} (f : Sum.inl X ⟶ Sum.inr Y) : False := by
  

Proof state:
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
X : C
Y : D
f : inl X ⟶ inr Y
⊢ False

Next tactic:
cases f
@[aesop norm -10 destruct (rule_sets [CategoryTheory])]
theorem hom_inr_inl_false {X : C} {Y : D} (f : Sum.inr X ⟶ Sum.inl Y) : False := by
  

Proof state:
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
X : C
Y : D
f : inr X ⟶ inl Y
⊢ False

Next tactic:
cases f
/-- The functor exchanging two direct summand categories. -/
def swap : Sum C D ⥤ Sum D C where
  obj X :=
    match X with
    | inl X => inr X
    | inr X => inl X
  map := @fun X Y f =>
    match X, Y, f with
    | inl _, inl _, f => f
    | inr _, inr _, f => f
  map_comp := fun {X} {Y} {Z} _ _ =>
    match X, Y, Z with
    | inl X, inl Y, inl Z => by 

Proof state:
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
X✝ Y✝ Z✝ : C ⊕ D
X Y Z : C
x✝¹ : inl X ⟶ inl Y
x✝ : inl Y ⟶ inl Z
⊢ {
          obj := fun X =>
            match X with
            | inl X => inr X
            | inr X => inl X,
          map := fun X Y f =>
            match X, Y, f with
            | inl val, inl val_1, f => f
            | inr val, inr val_1, f => f }.map
      (x✝¹ ≫ x✝) =
    {
            obj := fun X =>
              match X with
              | inl X => inr X
              | inr X => inl X,
            map := fun X Y f =>
              match X, Y, f with
              | inl val, inl val_1, f => f
              | inr val, inr val_1, f => f }.map
        x✝¹ ≫
      {
            obj := fun X =>
              match X with
              | inl X => inr X
              | inr X => inl X,
            map := fun X Y f =>
              match X, Y, f with
              | inl val, inl val_1, f => f
              | inr val, inr val_1, f => f }.map
        x✝

Next tactic:
rfl
/-- The functor exchanging two direct summand categories. -/
def swap : Sum C D ⥤ Sum D C where
  obj X :=
    match X with
    | inl X => inr X
    | inr X => inl X
  map := @fun X Y f =>
    match X, Y, f with
    | inl _, inl _, f => f
    | inr _, inr _, f => f
  map_comp := fun {X} {Y} {Z} _ _ =>
    match X, Y, Z with
    | inl X, inl Y, inl Z => by rfl
    | inr X, inr Y, inr Z => by 

Proof state:
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
X✝ Y✝ Z✝ : C ⊕ D
X Y Z : D
x✝¹ : inr X ⟶ inr Y
x✝ : inr Y ⟶ inr Z
⊢ {
          obj := fun X =>
            match X with
            | inl X => inr X
            | inr X => inl X,
          map := fun X Y f =>
            match X, Y, f with
            | inl val, inl val_1, f => f
            | inr val, inr val_1, f => f }.map
      (x✝¹ ≫ x✝) =
    {
            obj := fun X =>
              match X with
              | inl X => inr X
              | inr X => inl X,
            map := fun X Y f =>
              match X, Y, f with
              | inl val, inl val_1, f => f
              | inr val, inr val_1, f => f }.map
        x✝¹ ≫
      {
            obj := fun X =>
              match X with
              | inl X => inr X
              | inr X => inl X,
            map := fun X Y f =>
              match X, Y, f with
              | inl val, inl val_1, f => f
              | inr val, inr val_1, f => f }.map
        x✝

Next tactic:
rfl
/-- `swap` gives an equivalence between `C ⊕ D` and `D ⊕ C`. -/
def equivalence : Sum C D ≌ Sum D C :=
  Equivalence.mk (swap C D) (swap D C)
    (NatIso.ofComponents (fun X => eqToIso (by 

Proof state:
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
X : C ⊕ D
⊢ (𝟭 (C ⊕ D)).obj X = (swap C D ⋙ swap D C).obj X

Next tactic:
cases X
/-- `swap` gives an equivalence between `C ⊕ D` and `D ⊕ C`. -/
def equivalence : Sum C D ≌ Sum D C :=
  Equivalence.mk (swap C D) (swap D C)
    (NatIso.ofComponents (fun X => eqToIso (by cases X <;> 

Proof state:
case inl
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
val✝ : C
⊢ (𝟭 (C ⊕ D)).obj (inl val✝) = (swap C D ⋙ swap D C).obj (inl val✝)

Next tactic:
rfl
/-- `swap` gives an equivalence between `C ⊕ D` and `D ⊕ C`. -/
def equivalence : Sum C D ≌ Sum D C :=
  Equivalence.mk (swap C D) (swap D C)
    (NatIso.ofComponents (fun X => eqToIso (by cases X <;> 

Proof state:
case inr
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
val✝ : D
⊢ (𝟭 (C ⊕ D)).obj (inr val✝) = (swap C D ⋙ swap D C).obj (inr val✝)

Next tactic:
rfl
/-- `swap` gives an equivalence between `C ⊕ D` and `D ⊕ C`. -/
def equivalence : Sum C D ≌ Sum D C :=
  Equivalence.mk (swap C D) (swap D C)
    (NatIso.ofComponents (fun X => eqToIso (by cases X <;> rfl)))
    (NatIso.ofComponents (fun X => eqToIso (by 

Proof state:
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
X : D ⊕ C
⊢ (swap D C ⋙ swap C D).obj X = (𝟭 (D ⊕ C)).obj X

Next tactic:
cases X
/-- `swap` gives an equivalence between `C ⊕ D` and `D ⊕ C`. -/
def equivalence : Sum C D ≌ Sum D C :=
  Equivalence.mk (swap C D) (swap D C)
    (NatIso.ofComponents (fun X => eqToIso (by cases X <;> rfl)))
    (NatIso.ofComponents (fun X => eqToIso (by cases X <;> 

Proof state:
case inl
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
val✝ : D
⊢ (swap D C ⋙ swap C D).obj (inl val✝) = (𝟭 (D ⊕ C)).obj (inl val✝)

Next tactic:
rfl
/-- `swap` gives an equivalence between `C ⊕ D` and `D ⊕ C`. -/
def equivalence : Sum C D ≌ Sum D C :=
  Equivalence.mk (swap C D) (swap D C)
    (NatIso.ofComponents (fun X => eqToIso (by cases X <;> rfl)))
    (NatIso.ofComponents (fun X => eqToIso (by cases X <;> 

Proof state:
case inr
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
val✝ : C
⊢ (swap D C ⋙ swap C D).obj (inr val✝) = (𝟭 (D ⊕ C)).obj (inr val✝)

Next tactic:
rfl
instance isEquivalence : IsEquivalence (swap C D) :=
  (by 

Proof state:
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
⊢ IsEquivalence (equivalence C D).functor

Next tactic:
infer_instance
/-- The sum of two functors. -/
def sum (F : A ⥤ B) (G : C ⥤ D) : Sum A C ⥤ Sum B D
    where
  obj X :=
    match X with
    | inl X => inl (F.obj X)
    | inr X => inr (G.obj X)
  map := @fun X Y f =>
    match X, Y, f with
    | inl X, inl Y, f => F.map f
    | inr X, inr Y, f => G.map f
  map_id := @fun X => by 

Proof state:
A : Type u₁
inst✝³ : Category.{v₁, u₁} A
B : Type u₁
inst✝² : Category.{v₁, u₁} B
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
F : A ⥤ B
G : C ⥤ D
X : A ⊕ C
⊢ {
          obj := fun X =>
            match X with
            | inl X => inl (F.obj X)
            | inr X => inr (G.obj X),
          map := fun X Y f =>
            match X, Y, f with
            | inl X, inl Y, f => F.map f
            | inr X, inr Y, f => G.map f }.map
      (𝟙 X) =
    𝟙
      ({
            obj := fun X =>
              match X with
              | inl X => inl (F.obj X)
              | inr X => inr (G.obj X),
            map := fun X Y f =>
              match X, Y, f with
              | inl X, inl Y, f => F.map f
              | inr X, inr Y, f => G.map f }.obj
        X)

Next tactic:
cases X
/-- The sum of two functors. -/
def sum (F : A ⥤ B) (G : C ⥤ D) : Sum A C ⥤ Sum B D
    where
  obj X :=
    match X with
    | inl X => inl (F.obj X)
    | inr X => inr (G.obj X)
  map := @fun X Y f =>
    match X, Y, f with
    | inl X, inl Y, f => F.map f
    | inr X, inr Y, f => G.map f
  map_id := @fun X => by cases X <;> (

Proof state:
case inl
A : Type u₁
inst✝³ : Category.{v₁, u₁} A
B : Type u₁
inst✝² : Category.{v₁, u₁} B
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
F : A ⥤ B
G : C ⥤ D
val✝ : A
⊢ {
          obj := fun X =>
            match X with
            | inl X => inl (F.obj X)
            | inr X => inr (G.obj X),
          map := fun X Y f =>
            match X, Y, f with
            | inl X, inl Y, f => F.map f
            | inr X, inr Y, f => G.map f }.map
      (𝟙 (inl val✝)) =
    𝟙
      ({
            obj := fun X =>
              match X with
              | inl X => inl (F.obj X)
              | inr X => inr (G.obj X),
            map := fun X Y f =>
              match X, Y, f with
              | inl X, inl Y, f => F.map f
              | inr X, inr Y, f => G.map f }.obj
        (inl val✝))

Next tactic:
erw [Functor.map_id]
/-- The sum of two functors. -/
def sum (F : A ⥤ B) (G : C ⥤ D) : Sum A C ⥤ Sum B D
    where
  obj X :=
    match X with
    | inl X => inl (F.obj X)
    | inr X => inr (G.obj X)
  map := @fun X Y f =>
    match X, Y, f with
    | inl X, inl Y, f => F.map f
    | inr X, inr Y, f => G.map f
  map_id := @fun X => by cases X <;> (erw [Functor.map_id]; 

Proof state:
case inl
A : Type u₁
inst✝³ : Category.{v₁, u₁} A
B : Type u₁
inst✝² : Category.{v₁, u₁} B
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
F : A ⥤ B
G : C ⥤ D
val✝ : A
⊢ 𝟙 (F.obj val✝) =
    𝟙
      ({
            obj := fun X =>
              match X with
              | inl X => inl (F.obj X)
              | inr X => inr (G.obj X),
            map := fun X Y f =>
              match X, Y, f with
              | inl X, inl Y, f => F.map f
              | inr X, inr Y, f => G.map f }.obj
        (inl val✝))

Next tactic:
rfl
/-- The sum of two functors. -/
def sum (F : A ⥤ B) (G : C ⥤ D) : Sum A C ⥤ Sum B D
    where
  obj X :=
    match X with
    | inl X => inl (F.obj X)
    | inr X => inr (G.obj X)
  map := @fun X Y f =>
    match X, Y, f with
    | inl X, inl Y, f => F.map f
    | inr X, inr Y, f => G.map f
  map_id := @fun X => by cases X <;> (

Proof state:
case inr
A : Type u₁
inst✝³ : Category.{v₁, u₁} A
B : Type u₁
inst✝² : Category.{v₁, u₁} B
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
F : A ⥤ B
G : C ⥤ D
val✝ : C
⊢ {
          obj := fun X =>
            match X with
            | inl X => inl (F.obj X)
            | inr X => inr (G.obj X),
          map := fun X Y f =>
            match X, Y, f with
            | inl X, inl Y, f => F.map f
            | inr X, inr Y, f => G.map f }.map
      (𝟙 (inr val✝)) =
    𝟙
      ({
            obj := fun X =>
              match X with
              | inl X => inl (F.obj X)
              | inr X => inr (G.obj X),
            map := fun X Y f =>
              match X, Y, f with
              | inl X, inl Y, f => F.map f
              | inr X, inr Y, f => G.map f }.obj
        (inr val✝))

Next tactic:
erw [Functor.map_id]
/-- The sum of two functors. -/
def sum (F : A ⥤ B) (G : C ⥤ D) : Sum A C ⥤ Sum B D
    where
  obj X :=
    match X with
    | inl X => inl (F.obj X)
    | inr X => inr (G.obj X)
  map := @fun X Y f =>
    match X, Y, f with
    | inl X, inl Y, f => F.map f
    | inr X, inr Y, f => G.map f
  map_id := @fun X => by cases X <;> (erw [Functor.map_id]; 

Proof state:
case inr
A : Type u₁
inst✝³ : Category.{v₁, u₁} A
B : Type u₁
inst✝² : Category.{v₁, u₁} B
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₁
inst✝ : Category.{v₁, u₁} D
F : A ⥤ B
G : C ⥤ D
val✝ : C
⊢ 𝟙 (G.obj val✝) =
    𝟙
      ({
            obj := fun X =>
              match X with
              | inl X => inl (F.obj X)
              | inr X => inr (G.obj X),
            map := fun X Y f =>
              match X, Y, f with
              | inl X, inl Y, f => F.map f
              | inr X, inr Y, f => G.map f }.obj
        (inr val✝))

Next tactic:
rfl