l3lab/ntp-mathlib huggingface dataset:
/-- If all its Sylow subgroups are normal, then a finite group is isomorphic to the direct product
of these Sylow subgroups.
-/
noncomputable def directProductOfNormal [Fintype G]
    (hn : ∀ {p : ℕ} [Fact p.Prime] (P : Sylow p G), (↑P : Subgroup G).Normal) :
    (∀ p : (card G).primeFactors, ∀ P : Sylow p G, (↑P : Subgroup G)) ≃* G := by
  set ps := (Fintype.card G).primeFactors
  -- “The” Sylow subgroup for p
  let P : ∀ p, Sylow p G := default
  have hcomm : Pairwise fun p₁ p₂ : ps => ∀ x y : G, x ∈ P p₁ → y ∈ P p₂ → Commute x y := by
    rintro ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ hne
    haveI hp₁' := Fact.mk (Nat.prime_of_mem_primeFactors hp₁)
    haveI hp₂' := Fact.mk (Nat.prime_of_mem_primeFactors hp₂)
    have hne' : p₁ ≠ p₂ := by simpa using hne
    apply Subgroup.commute_of_normal_of_disjoint _ _ (hn (P p₁)) (hn (P p₂))
    apply IsPGroup.disjoint_of_ne p₁ p₂ hne' _ _ (P p₁).isPGroup' (P p₂).isPGroup'
  refine' MulEquiv.trans (N := ∀ p : ps, P p) _ _
  -- There is only one Sylow subgroup for each p, so the inner product is trivial
  show (∀ p : ps, ∀ P : Sylow p G, P) ≃* ∀ p : ps, P p
  · -- here we need to help the elaborator with an explicit instantiation
    apply @MulEquiv.piCongrRight ps (fun p => ∀ P : Sylow p G, P) (fun p => P p) _ _
    rintro ⟨p, hp⟩
    haveI hp' := Fact.mk (Nat.prime_of_mem_primeFactors hp)
    letI := unique_of_normal _ (hn (P p))
    apply MulEquiv.piUnique
  show (∀ p : ps, P p) ≃* G
  apply MulEquiv.ofBijective (Subgroup.noncommPiCoprod hcomm)
  apply (bijective_iff_injective_and_card _).mpr
  constructor
  show Injective _
  · apply Subgroup.injective_noncommPiCoprod_of_independent
    apply independent_of_coprime_order hcomm
    rintro ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ hne
    haveI hp₁' := Fact.mk (Nat.prime_of_mem_primeFactors hp₁)
    haveI hp₂' := Fact.mk (Nat.prime_of_mem_primeFactors hp₂)
    have hne' : p₁ ≠ p₂ := by simpa using hne
    apply IsPGroup.coprime_card_of_ne p₁ p₂ hne' _ _ (P p₁).isPGroup' (P p₂).isPGroup'
  show card (∀ p : ps, P p) = card G
  · calc
      card (∀ p : ps, P p) = ∏ p : ps, card (P p) := Fintype.card_pi
      _ = ∏ p : ps, p.1 ^ (card G).factorization p.1 := by
        

Proof state:
G : Type u
α : Type v
β : Type w
inst✝¹ : Group G
inst✝ : Fintype G
hn : ∀ {p : ℕ} [inst : Fact (Nat.Prime p)] (P : Sylow p G), Normal ↑P
ps : Finset ℕ := (Fintype.card G).primeFactors
P : (p : ℕ) → Sylow p G := default
hcomm : _root_.Pairwise fun p₁ p₂ => ∀ (x y : G), x ∈ P ↑p₁ → y ∈ P ↑p₂ → Commute x y
⊢ ∏ p : { x // x ∈ ps }, Fintype.card ↥↑(P ↑p) = ∏ p : { x // x ∈ ps }, ↑p ^ (Nat.factorization (Fintype.card G)) ↑p

Next tactic:
congr 1 with ⟨p, hp⟩
/-- If all its Sylow subgroups are normal, then a finite group is isomorphic to the direct product
of these Sylow subgroups.
-/
noncomputable def directProductOfNormal [Fintype G]
    (hn : ∀ {p : ℕ} [Fact p.Prime] (P : Sylow p G), (↑P : Subgroup G).Normal) :
    (∀ p : (card G).primeFactors, ∀ P : Sylow p G, (↑P : Subgroup G)) ≃* G := by
  set ps := (Fintype.card G).primeFactors
  -- “The” Sylow subgroup for p
  let P : ∀ p, Sylow p G := default
  have hcomm : Pairwise fun p₁ p₂ : ps => ∀ x y : G, x ∈ P p₁ → y ∈ P p₂ → Commute x y := by
    rintro ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ hne
    haveI hp₁' := Fact.mk (Nat.prime_of_mem_primeFactors hp₁)
    haveI hp₂' := Fact.mk (Nat.prime_of_mem_primeFactors hp₂)
    have hne' : p₁ ≠ p₂ := by simpa using hne
    apply Subgroup.commute_of_normal_of_disjoint _ _ (hn (P p₁)) (hn (P p₂))
    apply IsPGroup.disjoint_of_ne p₁ p₂ hne' _ _ (P p₁).isPGroup' (P p₂).isPGroup'
  refine' MulEquiv.trans (N := ∀ p : ps, P p) _ _
  -- There is only one Sylow subgroup for each p, so the inner product is trivial
  show (∀ p : ps, ∀ P : Sylow p G, P) ≃* ∀ p : ps, P p
  · -- here we need to help the elaborator with an explicit instantiation
    apply @MulEquiv.piCongrRight ps (fun p => ∀ P : Sylow p G, P) (fun p => P p) _ _
    rintro ⟨p, hp⟩
    haveI hp' := Fact.mk (Nat.prime_of_mem_primeFactors hp)
    letI := unique_of_normal _ (hn (P p))
    apply MulEquiv.piUnique
  show (∀ p : ps, P p) ≃* G
  apply MulEquiv.ofBijective (Subgroup.noncommPiCoprod hcomm)
  apply (bijective_iff_injective_and_card _).mpr
  constructor
  show Injective _
  · apply Subgroup.injective_noncommPiCoprod_of_independent
    apply independent_of_coprime_order hcomm
    rintro ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ hne
    haveI hp₁' := Fact.mk (Nat.prime_of_mem_primeFactors hp₁)
    haveI hp₂' := Fact.mk (Nat.prime_of_mem_primeFactors hp₂)
    have hne' : p₁ ≠ p₂ := by simpa using hne
    apply IsPGroup.coprime_card_of_ne p₁ p₂ hne' _ _ (P p₁).isPGroup' (P p₂).isPGroup'
  show card (∀ p : ps, P p) = card G
  · calc
      card (∀ p : ps, P p) = ∏ p : ps, card (P p) := Fintype.card_pi
      _ = ∏ p : ps, p.1 ^ (card G).factorization p.1 := by
        congr 1 with ⟨p, hp⟩
        

Proof state:
case e_f.h.mk
G : Type u
α : Type v
β : Type w
inst✝¹ : Group G
inst✝ : Fintype G
hn : ∀ {p : ℕ} [inst : Fact (Nat.Prime p)] (P : Sylow p G), Normal ↑P
ps : Finset ℕ := (Fintype.card G).primeFactors
P : (p : ℕ) → Sylow p G := default
hcomm : _root_.Pairwise fun p₁ p₂ => ∀ (x y : G), x ∈ P ↑p₁ → y ∈ P ↑p₂ → Commute x y
p : ℕ
hp : p ∈ ps
⊢ Fintype.card ↥↑(P ↑{ val := p, property := hp }) =
    ↑{ val := p, property := hp } ^ (Nat.factorization (Fintype.card G)) ↑{ val := p, property := hp }

Next tactic:
exact @card_eq_multiplicity _ _ _ p ⟨Nat.prime_of_mem_primeFactors hp⟩ (P p)
instance localization_unit_isIso' (R : CommRingCat) :
    @IsIso CommRingCat _ R _ (CommRingCat.ofHom <| algebraMap R (Localization.Away (1 : R))) := by
  

Proof state:
R : CommRingCat
⊢ IsIso (CommRingCat.ofHom (algebraMap (↑R) (Localization.Away 1)))

Next tactic:
cases R
instance localization_unit_isIso' (R : CommRingCat) :
    @IsIso CommRingCat _ R _ (CommRingCat.ofHom <| algebraMap R (Localization.Away (1 : R))) := by
  cases R
  

Proof state:
case mk
α✝ : Type ?u.2113
str✝ : CommRing α✝
⊢ IsIso (CommRingCat.ofHom (algebraMap (↑(Bundled.mk α✝)) (Localization.Away 1)))

Next tactic:
exact localization_unit_isIso _
instance Localization.epi' {R : CommRingCat} (M : Submonoid R) :
    @Epi CommRingCat _ R _ (CommRingCat.ofHom <| algebraMap R <| Localization M : _) := by
  

Proof state:
R : CommRingCat
M : Submonoid ↑R
⊢ Epi (CommRingCat.ofHom (algebraMap (↑R) (Localization M)))

Next tactic:
rcases R with ⟨α, str⟩
instance Localization.epi' {R : CommRingCat} (M : Submonoid R) :
    @Epi CommRingCat _ R _ (CommRingCat.ofHom <| algebraMap R <| Localization M : _) := by
  rcases R with ⟨α, str⟩
  

Proof state:
case mk
α : Type ?u.6221
str : CommRing α
M : Submonoid ↑(Bundled.mk α)
⊢ Epi (CommRingCat.ofHom (algebraMap (↑(Bundled.mk α)) (Localization M)))

Next tactic:
exact IsLocalization.epi M _
theorem isLocalRingHom_of_iso {R S : CommRingCat} (f : R ≅ S) : IsLocalRingHom f.hom :=
  { map_nonunit := fun a ha => by
      

Proof state:
R S : CommRingCat
f : R ≅ S
a : ↑R
ha : IsUnit (f.hom a)
⊢ IsUnit a

Next tactic:
convert f.inv.isUnit_map ha
theorem isLocalRingHom_of_iso {R S : CommRingCat} (f : R ≅ S) : IsLocalRingHom f.hom :=
  { map_nonunit := fun a ha => by
      convert f.inv.isUnit_map ha
      

Proof state:
case h.e'_3
R S : CommRingCat
f : R ≅ S
a : ↑R
ha : IsUnit (f.hom a)
⊢ a = f.inv (f.hom a)

Next tactic:
exact (RingHom.congr_fun f.hom_inv_id _).symm
theorem coevaluation_apply_one :
    (coevaluation K V) (1 : K) =
      let bV := Basis.ofVectorSpace K V
      ∑ i : Basis.ofVectorSpaceIndex K V, bV i ⊗ₜ[K] bV.coord i := by
  

Proof state:
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
⊢ (coevaluation K V) 1 =
    let bV := Basis.ofVectorSpace K V;
    ∑ i : ↑(Basis.ofVectorSpaceIndex K V), bV i ⊗ₜ[K] Basis.coord bV i

Next tactic:
simp only [coevaluation, id]
theorem coevaluation_apply_one :
    (coevaluation K V) (1 : K) =
      let bV := Basis.ofVectorSpace K V
      ∑ i : Basis.ofVectorSpaceIndex K V, bV i ⊗ₜ[K] bV.coord i := by
  simp only [coevaluation, id]
  

Proof state:
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
⊢ ((Basis.constr (Basis.singleton Unit K) K) fun x =>
        ∑ i : ↑(Basis.ofVectorSpaceIndex K V),
          (Basis.ofVectorSpace K V) i ⊗ₜ[K] Basis.coord (Basis.ofVectorSpace K V) i)
      1 =
    ∑ i : ↑(Basis.ofVectorSpaceIndex K V), (Basis.ofVectorSpace K V) i ⊗ₜ[K] Basis.coord (Basis.ofVectorSpace K V) i

Next tactic:
rw [(Basis.singleton Unit K).constr_apply_fintype K]
theorem coevaluation_apply_one :
    (coevaluation K V) (1 : K) =
      let bV := Basis.ofVectorSpace K V
      ∑ i : Basis.ofVectorSpaceIndex K V, bV i ⊗ₜ[K] bV.coord i := by
  simp only [coevaluation, id]
  rw [(Basis.singleton Unit K).constr_apply_fintype K]
  

Proof state:
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
⊢ ∑ i : Unit,
      (Basis.equivFun (Basis.singleton Unit K)) 1 i •
        ∑ i : ↑(Basis.ofVectorSpaceIndex K V),
          (Basis.ofVectorSpace K V) i ⊗ₜ[K] Basis.coord (Basis.ofVectorSpace K V) i =
    ∑ i : ↑(Basis.ofVectorSpaceIndex K V), (Basis.ofVectorSpace K V) i ⊗ₜ[K] Basis.coord (Basis.ofVectorSpace K V) i

Next tactic:
simp only [Fintype.univ_punit, Finset.sum_const, one_smul, Basis.singleton_repr,
    Basis.equivFun_apply, Basis.coe_ofVectorSpace, one_nsmul, Finset.card_singleton]
/-- This lemma corresponds to one of the coherence laws for duals in rigid categories, see
  `CategoryTheory.Monoidal.Rigid`. -/
theorem contractLeft_assoc_coevaluation :
    (contractLeft K V).rTensor _ ∘ₗ
        (TensorProduct.assoc K _ _ _).symm.toLinearMap ∘ₗ
          (coevaluation K V).lTensor (Module.Dual K V) =
      (TensorProduct.lid K _).symm.toLinearMap ∘ₗ (TensorProduct.rid K _).toLinearMap := by
  

Proof state:
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
⊢ LinearMap.rTensor (Module.Dual K V) (contractLeft K V) ∘ₗ
      ↑(LinearEquiv.symm (TensorProduct.assoc K (Module.Dual K V) V (Module.Dual K V))) ∘ₗ
        LinearMap.lTensor (Module.Dual K V) (coevaluation K V) =
    ↑(LinearEquiv.symm (TensorProduct.lid K (Module.Dual K V))) ∘ₗ ↑(TensorProduct.rid K (Module.Dual K V))

Next tactic:
letI := Classical.decEq (Basis.ofVectorSpaceIndex K V)
/-- This lemma corresponds to one of the coherence laws for duals in rigid categories, see
  `CategoryTheory.Monoidal.Rigid`. -/
theorem contractLeft_assoc_coevaluation :
    (contractLeft K V).rTensor _ ∘ₗ
        (TensorProduct.assoc K _ _ _).symm.toLinearMap ∘ₗ
          (coevaluation K V).lTensor (Module.Dual K V) =
      (TensorProduct.lid K _).symm.toLinearMap ∘ₗ (TensorProduct.rid K _).toLinearMap := by
  letI := Classical.decEq (Basis.ofVectorSpaceIndex K V)
  

Proof state:
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
this : DecidableEq ↑(Basis.ofVectorSpaceIndex K V) := Classical.decEq ↑(Basis.ofVectorSpaceIndex K V)
⊢ LinearMap.rTensor (Module.Dual K V) (contractLeft K V) ∘ₗ
      ↑(LinearEquiv.symm (TensorProduct.assoc K (Module.Dual K V) V (Module.Dual K V))) ∘ₗ
        LinearMap.lTensor (Module.Dual K V) (coevaluation K V) =
    ↑(LinearEquiv.symm (TensorProduct.lid K (Module.Dual K V))) ∘ₗ ↑(TensorProduct.rid K (Module.Dual K V))

Next tactic:
apply TensorProduct.ext
/-- This lemma corresponds to one of the coherence laws for duals in rigid categories, see
  `CategoryTheory.Monoidal.Rigid`. -/
theorem contractLeft_assoc_coevaluation :
    (contractLeft K V).rTensor _ ∘ₗ
        (TensorProduct.assoc K _ _ _).symm.toLinearMap ∘ₗ
          (coevaluation K V).lTensor (Module.Dual K V) =
      (TensorProduct.lid K _).symm.toLinearMap ∘ₗ (TensorProduct.rid K _).toLinearMap := by
  letI := Classical.decEq (Basis.ofVectorSpaceIndex K V)
  apply TensorProduct.ext
  

Proof state:
case H
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
this : DecidableEq ↑(Basis.ofVectorSpaceIndex K V) := Classical.decEq ↑(Basis.ofVectorSpaceIndex K V)
⊢ LinearMap.compr₂ (mk K (Module.Dual K V) K)
      (LinearMap.rTensor (Module.Dual K V) (contractLeft K V) ∘ₗ
        ↑(LinearEquiv.symm (TensorProduct.assoc K (Module.Dual K V) V (Module.Dual K V))) ∘ₗ
          LinearMap.lTensor (Module.Dual K V) (coevaluation K V)) =
    LinearMap.compr₂ (mk K (Module.Dual K V) K)
      (↑(LinearEquiv.symm (TensorProduct.lid K (Module.Dual K V))) ∘ₗ ↑(TensorProduct.rid K (Module.Dual K V)))

Next tactic:
apply (Basis.ofVectorSpace K V).dualBasis.ext
/-- This lemma corresponds to one of the coherence laws for duals in rigid categories, see
  `CategoryTheory.Monoidal.Rigid`. -/
theorem contractLeft_assoc_coevaluation :
    (contractLeft K V).rTensor _ ∘ₗ
        (TensorProduct.assoc K _ _ _).symm.toLinearMap ∘ₗ
          (coevaluation K V).lTensor (Module.Dual K V) =
      (TensorProduct.lid K _).symm.toLinearMap ∘ₗ (TensorProduct.rid K _).toLinearMap := by
  letI := Classical.decEq (Basis.ofVectorSpaceIndex K V)
  apply TensorProduct.ext
  apply (Basis.ofVectorSpace K V).dualBasis.ext; 

Proof state:
case H
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
this : DecidableEq ↑(Basis.ofVectorSpaceIndex K V) := Classical.decEq ↑(Basis.ofVectorSpaceIndex K V)
⊢ ∀ (i : ↑(Basis.ofVectorSpaceIndex K V)),
    (LinearMap.compr₂ (mk K (Module.Dual K V) K)
          (LinearMap.rTensor (Module.Dual K V) (contractLeft K V) ∘ₗ
            ↑(LinearEquiv.symm (TensorProduct.assoc K (Module.Dual K V) V (Module.Dual K V))) ∘ₗ
              LinearMap.lTensor (Module.Dual K V) (coevaluation K V)))
        ((Basis.dualBasis (Basis.ofVectorSpace K V)) i) =
      (LinearMap.compr₂ (mk K (Module.Dual K V) K)
          (↑(LinearEquiv.symm (TensorProduct.lid K (Module.Dual K V))) ∘ₗ ↑(TensorProduct.rid K (Module.Dual K V))))
        ((Basis.dualBasis (Basis.ofVectorSpace K V)) i)

Next tactic:
intro j
/-- This lemma corresponds to one of the coherence laws for duals in rigid categories, see
  `CategoryTheory.Monoidal.Rigid`. -/
theorem contractLeft_assoc_coevaluation :
    (contractLeft K V).rTensor _ ∘ₗ
        (TensorProduct.assoc K _ _ _).symm.toLinearMap ∘ₗ
          (coevaluation K V).lTensor (Module.Dual K V) =
      (TensorProduct.lid K _).symm.toLinearMap ∘ₗ (TensorProduct.rid K _).toLinearMap := by
  letI := Classical.decEq (Basis.ofVectorSpaceIndex K V)
  apply TensorProduct.ext
  apply (Basis.ofVectorSpace K V).dualBasis.ext; intro j; 

Proof state:
case H
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
this : DecidableEq ↑(Basis.ofVectorSpaceIndex K V) := Classical.decEq ↑(Basis.ofVectorSpaceIndex K V)
j : ↑(Basis.ofVectorSpaceIndex K V)
⊢ (LinearMap.compr₂ (mk K (Module.Dual K V) K)
        (LinearMap.rTensor (Module.Dual K V) (contractLeft K V) ∘ₗ
          ↑(LinearEquiv.symm (TensorProduct.assoc K (Module.Dual K V) V (Module.Dual K V))) ∘ₗ
            LinearMap.lTensor (Module.Dual K V) (coevaluation K V)))
      ((Basis.dualBasis (Basis.ofVectorSpace K V)) j) =
    (LinearMap.compr₂ (mk K (Module.Dual K V) K)
        (↑(LinearEquiv.symm (TensorProduct.lid K (Module.Dual K V))) ∘ₗ ↑(TensorProduct.rid K (Module.Dual K V))))
      ((Basis.dualBasis (Basis.ofVectorSpace K V)) j)

Next tactic:
apply LinearMap.ext_ring
/-- This lemma corresponds to one of the coherence laws for duals in rigid categories, see
  `CategoryTheory.Monoidal.Rigid`. -/
theorem contractLeft_assoc_coevaluation :
    (contractLeft K V).rTensor _ ∘ₗ
        (TensorProduct.assoc K _ _ _).symm.toLinearMap ∘ₗ
          (coevaluation K V).lTensor (Module.Dual K V) =
      (TensorProduct.lid K _).symm.toLinearMap ∘ₗ (TensorProduct.rid K _).toLinearMap := by
  letI := Classical.decEq (Basis.ofVectorSpaceIndex K V)
  apply TensorProduct.ext
  apply (Basis.ofVectorSpace K V).dualBasis.ext; intro j; apply LinearMap.ext_ring
  

Proof state:
case H.h
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
this : DecidableEq ↑(Basis.ofVectorSpaceIndex K V) := Classical.decEq ↑(Basis.ofVectorSpaceIndex K V)
j : ↑(Basis.ofVectorSpaceIndex K V)
⊢ ((LinearMap.compr₂ (mk K (Module.Dual K V) K)
          (LinearMap.rTensor (Module.Dual K V) (contractLeft K V) ∘ₗ
            ↑(LinearEquiv.symm (TensorProduct.assoc K (Module.Dual K V) V (Module.Dual K V))) ∘ₗ
              LinearMap.lTensor (Module.Dual K V) (coevaluation K V)))
        ((Basis.dualBasis (Basis.ofVectorSpace K V)) j))
      1 =
    ((LinearMap.compr₂ (mk K (Module.Dual K V) K)
          (↑(LinearEquiv.symm (TensorProduct.lid K (Module.Dual K V))) ∘ₗ ↑(TensorProduct.rid K (Module.Dual K V))))
        ((Basis.dualBasis (Basis.ofVectorSpace K V)) j))
      1

Next tactic:
rw [LinearMap.compr₂_apply, LinearMap.compr₂_apply, TensorProduct.mk_apply]
/-- This lemma corresponds to one of the coherence laws for duals in rigid categories, see
  `CategoryTheory.Monoidal.Rigid`. -/
theorem contractLeft_assoc_coevaluation :
    (contractLeft K V).rTensor _ ∘ₗ
        (TensorProduct.assoc K _ _ _).symm.toLinearMap ∘ₗ
          (coevaluation K V).lTensor (Module.Dual K V) =
      (TensorProduct.lid K _).symm.toLinearMap ∘ₗ (TensorProduct.rid K _).toLinearMap := by
  letI := Classical.decEq (Basis.ofVectorSpaceIndex K V)
  apply TensorProduct.ext
  apply (Basis.ofVectorSpace K V).dualBasis.ext; intro j; apply LinearMap.ext_ring
  rw [LinearMap.compr₂_apply, LinearMap.compr₂_apply, TensorProduct.mk_apply]
  

Proof state:
case H.h
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
this : DecidableEq ↑(Basis.ofVectorSpaceIndex K V) := Classical.decEq ↑(Basis.ofVectorSpaceIndex K V)
j : ↑(Basis.ofVectorSpaceIndex K V)
⊢ (LinearMap.rTensor (Module.Dual K V) (contractLeft K V) ∘ₗ
        ↑(LinearEquiv.symm (TensorProduct.assoc K (Module.Dual K V) V (Module.Dual K V))) ∘ₗ
          LinearMap.lTensor (Module.Dual K V) (coevaluation K V))
      ((Basis.dualBasis (Basis.ofVectorSpace K V)) j ⊗ₜ[K] 1) =
    (↑(LinearEquiv.symm (TensorProduct.lid K (Module.Dual K V))) ∘ₗ ↑(TensorProduct.rid K (Module.Dual K V)))
      ((Basis.dualBasis (Basis.ofVectorSpace K V)) j ⊗ₜ[K] 1)

Next tactic:
simp only [LinearMap.coe_comp, Function.comp_apply, LinearEquiv.coe_toLinearMap]
/-- This lemma corresponds to one of the coherence laws for duals in rigid categories, see
  `CategoryTheory.Monoidal.Rigid`. -/
theorem contractLeft_assoc_coevaluation :
    (contractLeft K V).rTensor _ ∘ₗ
        (TensorProduct.assoc K _ _ _).symm.toLinearMap ∘ₗ
          (coevaluation K V).lTensor (Module.Dual K V) =
      (TensorProduct.lid K _).symm.toLinearMap ∘ₗ (TensorProduct.rid K _).toLinearMap := by
  letI := Classical.decEq (Basis.ofVectorSpaceIndex K V)
  apply TensorProduct.ext
  apply (Basis.ofVectorSpace K V).dualBasis.ext; intro j; apply LinearMap.ext_ring
  rw [LinearMap.compr₂_apply, LinearMap.compr₂_apply, TensorProduct.mk_apply]
  simp only [LinearMap.coe_comp, Function.comp_apply, LinearEquiv.coe_toLinearMap]
  

Proof state:
case H.h
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
this : DecidableEq ↑(Basis.ofVectorSpaceIndex K V) := Classical.decEq ↑(Basis.ofVectorSpaceIndex K V)
j : ↑(Basis.ofVectorSpaceIndex K V)
⊢ (LinearMap.rTensor (Module.Dual K V) (contractLeft K V))
      ((LinearEquiv.symm (TensorProduct.assoc K (Module.Dual K V) V (Module.Dual K V)))
        ((LinearMap.lTensor (Module.Dual K V) (coevaluation K V))
          ((Basis.dualBasis (Basis.ofVectorSpace K V)) j ⊗ₜ[K] 1))) =
    (LinearEquiv.symm (TensorProduct.lid K (Module.Dual K V)))
      ((TensorProduct.rid K (Module.Dual K V)) ((Basis.dualBasis (Basis.ofVectorSpace K V)) j ⊗ₜ[K] 1))

Next tactic:
rw [rid_tmul, one_smul, lid_symm_apply]
/-- This lemma corresponds to one of the coherence laws for duals in rigid categories, see
  `CategoryTheory.Monoidal.Rigid`. -/
theorem contractLeft_assoc_coevaluation :
    (contractLeft K V).rTensor _ ∘ₗ
        (TensorProduct.assoc K _ _ _).symm.toLinearMap ∘ₗ
          (coevaluation K V).lTensor (Module.Dual K V) =
      (TensorProduct.lid K _).symm.toLinearMap ∘ₗ (TensorProduct.rid K _).toLinearMap := by
  letI := Classical.decEq (Basis.ofVectorSpaceIndex K V)
  apply TensorProduct.ext
  apply (Basis.ofVectorSpace K V).dualBasis.ext; intro j; apply LinearMap.ext_ring
  rw [LinearMap.compr₂_apply, LinearMap.compr₂_apply, TensorProduct.mk_apply]
  simp only [LinearMap.coe_comp, Function.comp_apply, LinearEquiv.coe_toLinearMap]
  rw [rid_tmul, one_smul, lid_symm_apply]
  

Proof state:
case H.h
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
this : DecidableEq ↑(Basis.ofVectorSpaceIndex K V) := Classical.decEq ↑(Basis.ofVectorSpaceIndex K V)
j : ↑(Basis.ofVectorSpaceIndex K V)
⊢ (LinearMap.rTensor (Module.Dual K V) (contractLeft K V))
      ((LinearEquiv.symm (TensorProduct.assoc K (Module.Dual K V) V (Module.Dual K V)))
        ((LinearMap.lTensor (Module.Dual K V) (coevaluation K V))
          ((Basis.dualBasis (Basis.ofVectorSpace K V)) j ⊗ₜ[K] 1))) =
    1 ⊗ₜ[K] (Basis.dualBasis (Basis.ofVectorSpace K V)) j

Next tactic:
simp only [LinearEquiv.coe_toLinearMap, LinearMap.lTensor_tmul, coevaluation_apply_one]
/-- This lemma corresponds to one of the coherence laws for duals in rigid categories, see
  `CategoryTheory.Monoidal.Rigid`. -/
theorem contractLeft_assoc_coevaluation :
    (contractLeft K V).rTensor _ ∘ₗ
        (TensorProduct.assoc K _ _ _).symm.toLinearMap ∘ₗ
          (coevaluation K V).lTensor (Module.Dual K V) =
      (TensorProduct.lid K _).symm.toLinearMap ∘ₗ (TensorProduct.rid K _).toLinearMap := by
  letI := Classical.decEq (Basis.ofVectorSpaceIndex K V)
  apply TensorProduct.ext
  apply (Basis.ofVectorSpace K V).dualBasis.ext; intro j; apply LinearMap.ext_ring
  rw [LinearMap.compr₂_apply, LinearMap.compr₂_apply, TensorProduct.mk_apply]
  simp only [LinearMap.coe_comp, Function.comp_apply, LinearEquiv.coe_toLinearMap]
  rw [rid_tmul, one_smul, lid_symm_apply]
  simp only [LinearEquiv.coe_toLinearMap, LinearMap.lTensor_tmul, coevaluation_apply_one]
  

Proof state:
case H.h
K : Type u
inst✝³ : Field K
V : Type v
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
this : DecidableEq ↑(Basis.ofVectorSpaceIndex K V) := Classical.decEq ↑(Basis.ofVectorSpaceIndex K V)
j : ↑(Basis.ofVectorSpaceIndex K V)
⊢ (LinearMap.rTensor (Module.Dual K V) (contractLeft K V))
      ((LinearEquiv.symm (TensorProduct.assoc K (Module.Dual K V) V (Module.Dual K V)))
        ((Basis.dualBasis (Basis.ofVectorSpace K V)) j ⊗ₜ[K]
          ∑ i : ↑(Basis.ofVectorSpaceIndex K V),
            (Basis.ofVectorSpace K V) i ⊗ₜ[K] Basis.coord (Basis.ofVectorSpace K V) i)) =
    1 ⊗ₜ[K] (Basis.dualBasis (Basis.ofVectorSpace K V)) j

Next tactic:
rw [TensorProduct.tmul_sum, map_sum]