l3lab/ntp-mathlib huggingface dataset:
@[to_additive]
theorem injective_noncommPiCoprod_of_independent (hind : CompleteLattice.Independent H) :
    Function.Injective (noncommPiCoprod hcomm) := by
  apply MonoidHom.injective_noncommPiCoprod_of_independent
  · 

Proof state:
case hind
G : Type u_1
inst✝ : Group G
ι : Type u_2
hdec : DecidableEq ι
hfin : Fintype ι
H : ι → Subgroup G
f g : (i : ι) → ↥(H i)
hcomm : ∀ (i j : ι), i ≠ j → ∀ (x y : G), x ∈ H i → y ∈ H j → Commute x y
hind : CompleteLattice.Independent H
⊢ CompleteLattice.Independent fun i => MonoidHom.range (Subgroup.subtype ((fun i => H i) i))

Next tactic:
simpa using hind
@[to_additive]
theorem injective_noncommPiCoprod_of_independent (hind : CompleteLattice.Independent H) :
    Function.Injective (noncommPiCoprod hcomm) := by
  apply MonoidHom.injective_noncommPiCoprod_of_independent
  · simpa using hind
  · 

Proof state:
case hinj
G : Type u_1
inst✝ : Group G
ι : Type u_2
hdec : DecidableEq ι
hfin : Fintype ι
H : ι → Subgroup G
f g : (i : ι) → ↥(H i)
hcomm : ∀ (i j : ι), i ≠ j → ∀ (x y : G), x ∈ H i → y ∈ H j → Commute x y
hind : CompleteLattice.Independent H
⊢ ∀ (i : ι), Function.Injective ⇑(Subgroup.subtype ((fun i => H i) i))

Next tactic:
intro i
@[to_additive]
theorem injective_noncommPiCoprod_of_independent (hind : CompleteLattice.Independent H) :
    Function.Injective (noncommPiCoprod hcomm) := by
  apply MonoidHom.injective_noncommPiCoprod_of_independent
  · simpa using hind
  · intro i
    

Proof state:
case hinj
G : Type u_1
inst✝ : Group G
ι : Type u_2
hdec : DecidableEq ι
hfin : Fintype ι
H : ι → Subgroup G
f g : (i : ι) → ↥(H i)
hcomm : ∀ (i j : ι), i ≠ j → ∀ (x y : G), x ∈ H i → y ∈ H j → Commute x y
hind : CompleteLattice.Independent H
i : ι
⊢ Function.Injective ⇑(Subgroup.subtype ((fun i => H i) i))

Next tactic:
exact Subtype.coe_injective
@[to_additive]
theorem independent_of_coprime_order [Finite ι] [∀ i, Fintype (H i)]
    (hcoprime : ∀ i j, i ≠ j → Nat.Coprime (Fintype.card (H i)) (Fintype.card (H j))) :
    CompleteLattice.Independent H := by
  

Proof state:
G : Type u_1
inst✝² : Group G
ι : Type u_2
hdec : DecidableEq ι
hfin : Fintype ι
H : ι → Subgroup G
f g : (i : ι) → ↥(H i)
hcomm : ∀ (i j : ι), i ≠ j → ∀ (x y : G), x ∈ H i → y ∈ H j → Commute x y
inst✝¹ : Finite ι
inst✝ : (i : ι) → Fintype ↥(H i)
hcoprime : ∀ (i j : ι), i ≠ j → Nat.Coprime (Fintype.card ↥(H i)) (Fintype.card ↥(H j))
⊢ CompleteLattice.Independent H

Next tactic:
simpa using
    MonoidHom.independent_range_of_coprime_order (fun i => (H i).subtype)
      (commute_subtype_of_commute hcomm) hcoprime
/-- `average k G` is invariant under left multiplication by elements of `G`.
-/
@[simp]
theorem mul_average_left (g : G) : ↑(Finsupp.single g 1) * average k G = average k G := by
  

Proof state:
k : Type u_1
G : Type u_2
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
g : G
⊢ (fun₀ | g => 1) * average k G = average k G

Next tactic:
simp only [mul_one, Finset.mul_sum, Algebra.mul_smul_comm, average, MonoidAlgebra.of_apply,
    Finset.sum_congr, MonoidAlgebra.single_mul_single]
/-- `average k G` is invariant under left multiplication by elements of `G`.
-/
@[simp]
theorem mul_average_left (g : G) : ↑(Finsupp.single g 1) * average k G = average k G := by
  simp only [mul_one, Finset.mul_sum, Algebra.mul_smul_comm, average, MonoidAlgebra.of_apply,
    Finset.sum_congr, MonoidAlgebra.single_mul_single]
  

Proof state:
k : Type u_1
G : Type u_2
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
g : G
⊢ ⅟↑(Fintype.card G) • ∑ x : G, single (g * x) 1 = ⅟↑(Fintype.card G) • ∑ x : G, single x 1

Next tactic:
set f : G → MonoidAlgebra k G := fun x => Finsupp.single x 1
/-- `average k G` is invariant under left multiplication by elements of `G`.
-/
@[simp]
theorem mul_average_left (g : G) : ↑(Finsupp.single g 1) * average k G = average k G := by
  simp only [mul_one, Finset.mul_sum, Algebra.mul_smul_comm, average, MonoidAlgebra.of_apply,
    Finset.sum_congr, MonoidAlgebra.single_mul_single]
  set f : G → MonoidAlgebra k G := fun x => Finsupp.single x 1
  

Proof state:
k : Type u_1
G : Type u_2
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
g : G
f : G → MonoidAlgebra k G := fun x => fun₀ | x => 1
⊢ ⅟↑(Fintype.card G) • ∑ x : G, single (g * x) 1 = ⅟↑(Fintype.card G) • Finset.sum Finset.univ f

Next tactic:
show ⅟ (Fintype.card G : k) • ∑ x : G, f (g * x) = ⅟ (Fintype.card G : k) • ∑ x : G, f x
/-- `average k G` is invariant under left multiplication by elements of `G`.
-/
@[simp]
theorem mul_average_left (g : G) : ↑(Finsupp.single g 1) * average k G = average k G := by
  simp only [mul_one, Finset.mul_sum, Algebra.mul_smul_comm, average, MonoidAlgebra.of_apply,
    Finset.sum_congr, MonoidAlgebra.single_mul_single]
  set f : G → MonoidAlgebra k G := fun x => Finsupp.single x 1
  show ⅟ (Fintype.card G : k) • ∑ x : G, f (g * x) = ⅟ (Fintype.card G : k) • ∑ x : G, f x
  

Proof state:
k : Type u_1
G : Type u_2
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
g : G
f : G → MonoidAlgebra k G := fun x => fun₀ | x => 1
⊢ ⅟↑(Fintype.card G) • ∑ x : G, f (g * x) = ⅟↑(Fintype.card G) • ∑ x : G, f x

Next tactic:
rw [Function.Bijective.sum_comp (Group.mulLeft_bijective g) _]
/-- `average k G` is invariant under right multiplication by elements of `G`.
-/
@[simp]
theorem mul_average_right (g : G) : average k G * ↑(Finsupp.single g 1) = average k G := by
  

Proof state:
k : Type u_1
G : Type u_2
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
g : G
⊢ (average k G * fun₀ | g => 1) = average k G

Next tactic:
simp only [mul_one, Finset.sum_mul, Algebra.smul_mul_assoc, average, MonoidAlgebra.of_apply,
    Finset.sum_congr, MonoidAlgebra.single_mul_single]
/-- `average k G` is invariant under right multiplication by elements of `G`.
-/
@[simp]
theorem mul_average_right (g : G) : average k G * ↑(Finsupp.single g 1) = average k G := by
  simp only [mul_one, Finset.sum_mul, Algebra.smul_mul_assoc, average, MonoidAlgebra.of_apply,
    Finset.sum_congr, MonoidAlgebra.single_mul_single]
  

Proof state:
k : Type u_1
G : Type u_2
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
g : G
⊢ ⅟↑(Fintype.card G) • ∑ x : G, single (x * g) 1 = ⅟↑(Fintype.card G) • ∑ x : G, single x 1

Next tactic:
set f : G → MonoidAlgebra k G := fun x => Finsupp.single x 1
/-- `average k G` is invariant under right multiplication by elements of `G`.
-/
@[simp]
theorem mul_average_right (g : G) : average k G * ↑(Finsupp.single g 1) = average k G := by
  simp only [mul_one, Finset.sum_mul, Algebra.smul_mul_assoc, average, MonoidAlgebra.of_apply,
    Finset.sum_congr, MonoidAlgebra.single_mul_single]
  set f : G → MonoidAlgebra k G := fun x => Finsupp.single x 1
  

Proof state:
k : Type u_1
G : Type u_2
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
g : G
f : G → MonoidAlgebra k G := fun x => fun₀ | x => 1
⊢ ⅟↑(Fintype.card G) • ∑ x : G, single (x * g) 1 = ⅟↑(Fintype.card G) • Finset.sum Finset.univ f

Next tactic:
show ⅟ (Fintype.card G : k) • ∑ x : G, f (x * g) = ⅟ (Fintype.card G : k) • ∑ x : G, f x
/-- `average k G` is invariant under right multiplication by elements of `G`.
-/
@[simp]
theorem mul_average_right (g : G) : average k G * ↑(Finsupp.single g 1) = average k G := by
  simp only [mul_one, Finset.sum_mul, Algebra.smul_mul_assoc, average, MonoidAlgebra.of_apply,
    Finset.sum_congr, MonoidAlgebra.single_mul_single]
  set f : G → MonoidAlgebra k G := fun x => Finsupp.single x 1
  show ⅟ (Fintype.card G : k) • ∑ x : G, f (x * g) = ⅟ (Fintype.card G : k) • ∑ x : G, f x
  

Proof state:
k : Type u_1
G : Type u_2
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
g : G
f : G → MonoidAlgebra k G := fun x => fun₀ | x => 1
⊢ ⅟↑(Fintype.card G) • ∑ x : G, f (x * g) = ⅟↑(Fintype.card G) • ∑ x : G, f x

Next tactic:
rw [Function.Bijective.sum_comp (Group.mulRight_bijective g) _]
/-- The subspace of invariants, consisting of the vectors fixed by all elements of `G`.
-/
def invariants : Submodule k V where
  carrier := setOf fun v => ∀ g : G, ρ g v = v
  zero_mem' g := by simp only [map_zero]
  add_mem' hv hw g := by 

Proof state:
k : Type u_1
G : Type u_2
V : Type u_3
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : AddCommMonoid V
inst✝ : Module k V
ρ : Representation k G V
a✝ b✝ : V
hv : a✝ ∈ {v | ∀ (g : G), (ρ g) v = v}
hw : b✝ ∈ {v | ∀ (g : G), (ρ g) v = v}
g : G
⊢ (ρ g) (a✝ + b✝) = a✝ + b✝

Next tactic:
simp only [hv g, hw g, map_add]
/-- The subspace of invariants, consisting of the vectors fixed by all elements of `G`.
-/
def invariants : Submodule k V where
  carrier := setOf fun v => ∀ g : G, ρ g v = v
  zero_mem' g := by 

Proof state:
k : Type u_1
G : Type u_2
V : Type u_3
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : AddCommMonoid V
inst✝ : Module k V
ρ : Representation k G V
g : G
⊢ (ρ g) 0 = 0

Next tactic:
simp only [map_zero]
/-- The subspace of invariants, consisting of the vectors fixed by all elements of `G`.
-/
def invariants : Submodule k V where
  carrier := setOf fun v => ∀ g : G, ρ g v = v
  zero_mem' g := by simp only [map_zero]
  add_mem' hv hw g := by simp only [hv g, hw g, map_add]
  smul_mem' r v hv g := by 

Proof state:
k : Type u_1
G : Type u_2
V : Type u_3
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : AddCommMonoid V
inst✝ : Module k V
ρ : Representation k G V
r : k
v : V
hv :
  v ∈
    {
          toAddSubsemigroup :=
            { carrier := {v | ∀ (g : G), (ρ g) v = v},
              add_mem' :=
                (_ :
                  ∀ {a b : V},
                    a ∈ {v | ∀ (g : G), (ρ g) v = v} →
                      b ∈ {v | ∀ (g : G), (ρ g) v = v} → ∀ (g : G), (ρ g) (a + b) = a + b) },
          zero_mem' := (_ : ∀ (g : G), (ρ g) 0 = 0) }.toAddSubsemigroup.carrier
g : G
⊢ (ρ g) (r • v) = r • v

Next tactic:
simp only [hv g, LinearMap.map_smulₛₗ, RingHom.id_apply]
@[simp]
theorem mem_invariants (v : V) : v ∈ invariants ρ ↔ ∀ g : G, ρ g v = v := by 

Proof state:
k : Type u_1
G : Type u_2
V : Type u_3
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : AddCommMonoid V
inst✝ : Module k V
ρ : Representation k G V
v : V
⊢ v ∈ invariants ρ ↔ ∀ (g : G), (ρ g) v = v

Next tactic:
rfl
theorem invariants_eq_inter : (invariants ρ).carrier = ⋂ g : G, Function.fixedPoints (ρ g) := by
  

Proof state:
k : Type u_1
G : Type u_2
V : Type u_3
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : AddCommMonoid V
inst✝ : Module k V
ρ : Representation k G V
⊢ (invariants ρ).toAddSubmonoid.toAddSubsemigroup.carrier = ⋂ g, Function.fixedPoints ⇑(ρ g)

Next tactic:
ext
theorem invariants_eq_inter : (invariants ρ).carrier = ⋂ g : G, Function.fixedPoints (ρ g) := by
  ext; 

Proof state:
case h
k : Type u_1
G : Type u_2
V : Type u_3
inst✝³ : CommSemiring k
inst✝² : Group G
inst✝¹ : AddCommMonoid V
inst✝ : Module k V
ρ : Representation k G V
x✝ : V
⊢ x✝ ∈ (invariants ρ).toAddSubmonoid.toAddSubsemigroup.carrier ↔ x✝ ∈ ⋂ g, Function.fixedPoints ⇑(ρ g)

Next tactic:
simp [Function.IsFixedPt]
/-- The `averageMap` sends elements of `V` to the subspace of invariants.
-/
theorem averageMap_invariant (v : V) : averageMap ρ v ∈ invariants ρ := fun g => by
  

Proof state:
k : Type u_1
G : Type u_2
V : Type u_3
inst✝⁵ : CommSemiring k
inst✝⁴ : Group G
inst✝³ : AddCommMonoid V
inst✝² : Module k V
ρ : Representation k G V
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
v : V
g : G
⊢ (ρ g) ((averageMap ρ) v) = (averageMap ρ) v

Next tactic:
rw [averageMap, ← asAlgebraHom_single_one, ← LinearMap.mul_apply, ← map_mul (asAlgebraHom ρ),
    mul_average_left]
/-- The `averageMap` acts as the identity on the subspace of invariants.
-/
theorem averageMap_id (v : V) (hv : v ∈ invariants ρ) : averageMap ρ v = v := by
  

Proof state:
k : Type u_1
G : Type u_2
V : Type u_3
inst✝⁵ : CommSemiring k
inst✝⁴ : Group G
inst✝³ : AddCommMonoid V
inst✝² : Module k V
ρ : Representation k G V
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
v : V
hv : v ∈ invariants ρ
⊢ (averageMap ρ) v = v

Next tactic:
rw [mem_invariants] at hv
/-- The `averageMap` acts as the identity on the subspace of invariants.
-/
theorem averageMap_id (v : V) (hv : v ∈ invariants ρ) : averageMap ρ v = v := by
  rw [mem_invariants] at hv
  

Proof state:
k : Type u_1
G : Type u_2
V : Type u_3
inst✝⁵ : CommSemiring k
inst✝⁴ : Group G
inst✝³ : AddCommMonoid V
inst✝² : Module k V
ρ : Representation k G V
inst✝¹ : Fintype G
inst✝ : Invertible ↑(Fintype.card G)
v : V
hv : ∀ (g : G), (ρ g) v = v
⊢ (averageMap ρ) v = v

Next tactic:
simp [average, map_sum, hv, Finset.card_univ, nsmul_eq_smul_cast k _ v, smul_smul]
theorem mem_invariants_iff_comm {X Y : Rep k G} (f : X.V →ₗ[k] Y.V) (g : G) :
    (linHom X.ρ Y.ρ) g f = f ↔ f.comp (X.ρ g) = (Y.ρ g).comp f := by
  

Proof state:
k : Type u
inst✝ : CommRing k
G : GroupCat
X Y : Rep k ↑G
f : ↑X.V →ₗ[k] ↑Y.V
g : ↑G
⊢ ((linHom (Rep.ρ X) (Rep.ρ Y)) g) f = f ↔ f ∘ₗ (Rep.ρ X) g = (Rep.ρ Y) g ∘ₗ f

Next tactic:
dsimp
theorem mem_invariants_iff_comm {X Y : Rep k G} (f : X.V →ₗ[k] Y.V) (g : G) :
    (linHom X.ρ Y.ρ) g f = f ↔ f.comp (X.ρ g) = (Y.ρ g).comp f := by
  dsimp
  

Proof state:
k : Type u
inst✝ : CommRing k
G : GroupCat
X Y : Rep k ↑G
f : ↑X.V →ₗ[k] ↑Y.V
g : ↑G
⊢ (Rep.ρ Y) g ∘ₗ f ∘ₗ (Rep.ρ X) g⁻¹ = f ↔ f ∘ₗ (Rep.ρ X) g = (Rep.ρ Y) g ∘ₗ f

Next tactic:
erw [← ρAut_apply_inv]
theorem mem_invariants_iff_comm {X Y : Rep k G} (f : X.V →ₗ[k] Y.V) (g : G) :
    (linHom X.ρ Y.ρ) g f = f ↔ f.comp (X.ρ g) = (Y.ρ g).comp f := by
  dsimp
  erw [← ρAut_apply_inv]
  

Proof state:
k : Type u
inst✝ : CommRing k
G : GroupCat
X Y : Rep k ↑G
f : ↑X.V →ₗ[k] ↑Y.V
g : ↑G
⊢ (Rep.ρ Y) g ∘ₗ f ∘ₗ ((ρAut X) g).inv = f ↔ f ∘ₗ (Rep.ρ X) g = (Rep.ρ Y) g ∘ₗ f

Next tactic:
rw [← LinearMap.comp_assoc, ← ModuleCat.comp_def, ← ModuleCat.comp_def, Iso.inv_comp_eq,
    ρAut_apply_hom]
theorem mem_invariants_iff_comm {X Y : Rep k G} (f : X.V →ₗ[k] Y.V) (g : G) :
    (linHom X.ρ Y.ρ) g f = f ↔ f.comp (X.ρ g) = (Y.ρ g).comp f := by
  dsimp
  erw [← ρAut_apply_inv]
  rw [← LinearMap.comp_assoc, ← ModuleCat.comp_def, ← ModuleCat.comp_def, Iso.inv_comp_eq,
    ρAut_apply_hom]
  

Proof state:
k : Type u
inst✝ : CommRing k
G : GroupCat
X Y : Rep k ↑G
f : ↑X.V →ₗ[k] ↑Y.V
g : ↑G
⊢ f ≫ (Rep.ρ Y) g = X.ρ g ≫ f ↔ f ∘ₗ (Rep.ρ X) g = f ≫ (Rep.ρ Y) g

Next tactic:
exact comm
/-- The invariants of the representation `linHom X.ρ Y.ρ` correspond to the representation
homomorphisms from `X` to `Y`. -/
@[simps]
def invariantsEquivRepHom (X Y : Rep k G) : (linHom X.ρ Y.ρ).invariants ≃ₗ[k] X ⟶ Y where
  toFun f := ⟨f.val, fun g => (mem_invariants_iff_comm _ g).1 (f.property g)⟩
  map_add' _ _ := rfl
  map_smul' _ _ := rfl
  invFun f := ⟨f.hom, fun g => (mem_invariants_iff_comm _ g).2 (f.comm g)⟩
  left_inv _ := by 

Proof state:
k : Type u
inst✝ : CommRing k
G : GroupCat
X Y : Rep k ↑G
x✝ : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))
⊢ (fun f => { val := f.hom, property := (_ : ∀ (g : ↑G), ((linHom (Rep.ρ X) (Rep.ρ Y)) g) f.hom = f.hom) })
      (AddHom.toFun
        {
            toAddHom :=
              { toFun := fun f => Hom.mk ↑f,
                map_add' :=
                  (_ :
                    ∀ (x x_1 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                      (fun f => Hom.mk ↑f) (x + x_1) = (fun f => Hom.mk ↑f) (x + x_1)) },
            map_smul' :=
              (_ :
                ∀ (x : k) (x_1 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                  AddHom.toFun
                      { toFun := fun f => Hom.mk ↑f,
                        map_add' :=
                          (_ :
                            ∀ (x x_2 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                              (fun f => Hom.mk ↑f) (x + x_2) = (fun f => Hom.mk ↑f) (x + x_2)) }
                      (x • x_1) =
                    AddHom.toFun
                      { toFun := fun f => Hom.mk ↑f,
                        map_add' :=
                          (_ :
                            ∀ (x x_2 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                              (fun f => Hom.mk ↑f) (x + x_2) = (fun f => Hom.mk ↑f) (x + x_2)) }
                      (x • x_1)) }.toAddHom
        x✝) =
    x✝

Next tactic:
apply Subtype.ext
/-- The invariants of the representation `linHom X.ρ Y.ρ` correspond to the representation
homomorphisms from `X` to `Y`. -/
@[simps]
def invariantsEquivRepHom (X Y : Rep k G) : (linHom X.ρ Y.ρ).invariants ≃ₗ[k] X ⟶ Y where
  toFun f := ⟨f.val, fun g => (mem_invariants_iff_comm _ g).1 (f.property g)⟩
  map_add' _ _ := rfl
  map_smul' _ _ := rfl
  invFun f := ⟨f.hom, fun g => (mem_invariants_iff_comm _ g).2 (f.comm g)⟩
  left_inv _ := by apply Subtype.ext; 

Proof state:
case a
k : Type u
inst✝ : CommRing k
G : GroupCat
X Y : Rep k ↑G
x✝ : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))
⊢ ↑((fun f => { val := f.hom, property := (_ : ∀ (g : ↑G), ((linHom (Rep.ρ X) (Rep.ρ Y)) g) f.hom = f.hom) })
        (AddHom.toFun
          {
              toAddHom :=
                { toFun := fun f => Hom.mk ↑f,
                  map_add' :=
                    (_ :
                      ∀ (x x_1 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                        (fun f => Hom.mk ↑f) (x + x_1) = (fun f => Hom.mk ↑f) (x + x_1)) },
              map_smul' :=
                (_ :
                  ∀ (x : k) (x_1 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                    AddHom.toFun
                        { toFun := fun f => Hom.mk ↑f,
                          map_add' :=
                            (_ :
                              ∀ (x x_2 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                                (fun f => Hom.mk ↑f) (x + x_2) = (fun f => Hom.mk ↑f) (x + x_2)) }
                        (x • x_1) =
                      AddHom.toFun
                        { toFun := fun f => Hom.mk ↑f,
                          map_add' :=
                            (_ :
                              ∀ (x x_2 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                                (fun f => Hom.mk ↑f) (x + x_2) = (fun f => Hom.mk ↑f) (x + x_2)) }
                        (x • x_1)) }.toAddHom
          x✝)) =
    ↑x✝

Next tactic:
ext
/-- The invariants of the representation `linHom X.ρ Y.ρ` correspond to the representation
homomorphisms from `X` to `Y`. -/
@[simps]
def invariantsEquivRepHom (X Y : Rep k G) : (linHom X.ρ Y.ρ).invariants ≃ₗ[k] X ⟶ Y where
  toFun f := ⟨f.val, fun g => (mem_invariants_iff_comm _ g).1 (f.property g)⟩
  map_add' _ _ := rfl
  map_smul' _ _ := rfl
  invFun f := ⟨f.hom, fun g => (mem_invariants_iff_comm _ g).2 (f.comm g)⟩
  left_inv _ := by apply Subtype.ext; ext; 

Proof state:
case a.h
k : Type u
inst✝ : CommRing k
G : GroupCat
X Y : Rep k ↑G
x✝¹ : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))
x✝ : CoeSort.coe X
⊢ ↑((fun f => { val := f.hom, property := (_ : ∀ (g : ↑G), ((linHom (Rep.ρ X) (Rep.ρ Y)) g) f.hom = f.hom) })
          (AddHom.toFun
            {
                toAddHom :=
                  { toFun := fun f => Hom.mk ↑f,
                    map_add' :=
                      (_ :
                        ∀ (x x_1 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                          (fun f => Hom.mk ↑f) (x + x_1) = (fun f => Hom.mk ↑f) (x + x_1)) },
                map_smul' :=
                  (_ :
                    ∀ (x : k) (x_1 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                      AddHom.toFun
                          { toFun := fun f => Hom.mk ↑f,
                            map_add' :=
                              (_ :
                                ∀ (x x_2 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                                  (fun f => Hom.mk ↑f) (x + x_2) = (fun f => Hom.mk ↑f) (x + x_2)) }
                          (x • x_1) =
                        AddHom.toFun
                          { toFun := fun f => Hom.mk ↑f,
                            map_add' :=
                              (_ :
                                ∀ (x x_2 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                                  (fun f => Hom.mk ↑f) (x + x_2) = (fun f => Hom.mk ↑f) (x + x_2)) }
                          (x • x_1)) }.toAddHom
            x✝¹))
      x✝ =
    ↑x✝¹ x✝

Next tactic:
rfl
/-- The invariants of the representation `linHom X.ρ Y.ρ` correspond to the representation
homomorphisms from `X` to `Y`. -/
@[simps]
def invariantsEquivRepHom (X Y : Rep k G) : (linHom X.ρ Y.ρ).invariants ≃ₗ[k] X ⟶ Y where
  toFun f := ⟨f.val, fun g => (mem_invariants_iff_comm _ g).1 (f.property g)⟩
  map_add' _ _ := rfl
  map_smul' _ _ := rfl
  invFun f := ⟨f.hom, fun g => (mem_invariants_iff_comm _ g).2 (f.comm g)⟩
  left_inv _ := by apply Subtype.ext; ext; rfl -- Porting note: Added `apply Subtype.ext`
  right_inv _ := by 

Proof state:
k : Type u
inst✝ : CommRing k
G : GroupCat
X Y : Rep k ↑G
x✝ : X ⟶ Y
⊢ AddHom.toFun
      {
          toAddHom :=
            { toFun := fun f => Hom.mk ↑f,
              map_add' :=
                (_ :
                  ∀ (x x_1 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                    (fun f => Hom.mk ↑f) (x + x_1) = (fun f => Hom.mk ↑f) (x + x_1)) },
          map_smul' :=
            (_ :
              ∀ (x : k) (x_1 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                AddHom.toFun
                    { toFun := fun f => Hom.mk ↑f,
                      map_add' :=
                        (_ :
                          ∀ (x x_2 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                            (fun f => Hom.mk ↑f) (x + x_2) = (fun f => Hom.mk ↑f) (x + x_2)) }
                    (x • x_1) =
                  AddHom.toFun
                    { toFun := fun f => Hom.mk ↑f,
                      map_add' :=
                        (_ :
                          ∀ (x x_2 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                            (fun f => Hom.mk ↑f) (x + x_2) = (fun f => Hom.mk ↑f) (x + x_2)) }
                    (x • x_1)) }.toAddHom
      ((fun f => { val := f.hom, property := (_ : ∀ (g : ↑G), ((linHom (Rep.ρ X) (Rep.ρ Y)) g) f.hom = f.hom) }) x✝) =
    x✝

Next tactic:
ext
/-- The invariants of the representation `linHom X.ρ Y.ρ` correspond to the representation
homomorphisms from `X` to `Y`. -/
@[simps]
def invariantsEquivRepHom (X Y : Rep k G) : (linHom X.ρ Y.ρ).invariants ≃ₗ[k] X ⟶ Y where
  toFun f := ⟨f.val, fun g => (mem_invariants_iff_comm _ g).1 (f.property g)⟩
  map_add' _ _ := rfl
  map_smul' _ _ := rfl
  invFun f := ⟨f.hom, fun g => (mem_invariants_iff_comm _ g).2 (f.comm g)⟩
  left_inv _ := by apply Subtype.ext; ext; rfl -- Porting note: Added `apply Subtype.ext`
  right_inv _ := by ext; 

Proof state:
case h.h
k : Type u
inst✝ : CommRing k
G : GroupCat
X Y : Rep k ↑G
x✝¹ : X ⟶ Y
x✝ : ↑X.V
⊢ (AddHom.toFun
          {
              toAddHom :=
                { toFun := fun f => Hom.mk ↑f,
                  map_add' :=
                    (_ :
                      ∀ (x x_1 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                        (fun f => Hom.mk ↑f) (x + x_1) = (fun f => Hom.mk ↑f) (x + x_1)) },
              map_smul' :=
                (_ :
                  ∀ (x : k) (x_1 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                    AddHom.toFun
                        { toFun := fun f => Hom.mk ↑f,
                          map_add' :=
                            (_ :
                              ∀ (x x_2 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                                (fun f => Hom.mk ↑f) (x + x_2) = (fun f => Hom.mk ↑f) (x + x_2)) }
                        (x • x_1) =
                      AddHom.toFun
                        { toFun := fun f => Hom.mk ↑f,
                          map_add' :=
                            (_ :
                              ∀ (x x_2 : ↥(invariants (linHom (Rep.ρ X) (Rep.ρ Y)))),
                                (fun f => Hom.mk ↑f) (x + x_2) = (fun f => Hom.mk ↑f) (x + x_2)) }
                        (x • x_1)) }.toAddHom
          ((fun f => { val := f.hom, property := (_ : ∀ (g : ↑G), ((linHom (Rep.ρ X) (Rep.ρ Y)) g) f.hom = f.hom) })
            x✝¹)).hom
      x✝ =
    x✝¹.hom x✝

Next tactic:
rfl