l3lab/ntp-mathlib huggingface dataset:
theorem mul_assoc {na nb nc} (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M) :
    cast R M (add_assoc _ _ _) (a ₜ* b ₜ* c) = a ₜ* (b ₜ* c) := by
  let mul : ∀ n m : ℕ, (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M := fun n m =>
    (TensorProduct.mk R _ _).compr₂ ↑(mulEquiv : _ ≃ₗ[R] (⨂[R]^(n + m)) M)
  -- replace `a`, `b`, `c` with `tprod R a`, `tprod R b`, `tprod R c`
  let e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (add_assoc _ _ _)
  let lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ ((mul _ nc).compr₂ e.toLinearMap)).comp (mul na nb)
  have lhs_eq : ∀ a b c, lhs a b c = e (a ₜ* b ₜ* c) := fun _ _ _ => rfl
  let rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ (LinearMap.lflip (R := R)) <|
        (LinearMap.llcomp R _ _ _ (mul na _).flip).comp (mul nb nc)).flip
  have rhs_eq : ∀ a b c, rhs a b c = a ₜ* (b ₜ* c) := fun _ _ _ => rfl
  

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
na nb nc : ℕ
a : (⨂[R]^na) M
b : (⨂[R]^nb) M
c : (⨂[R]^nc) M
mul : (n m : ℕ) → (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M :=
  fun n m => LinearMap.compr₂ (TensorProduct.mk R ((⨂[R]^n) M) ((⨂[R]^m) M)) ↑mulEquiv
e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (_ : na + nb + nc = na + (nb + nc))
lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  (LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^(na + nb)) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
      (LinearMap.compr₂ (mul (na + nb) nc) ↑e) ∘ₗ
    mul na nb
lhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((lhs a) b) c = e (GradedMonoid.GMul.mul (GradedMonoid.GMul.mul a b) c)
rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  LinearMap.flip
    (((LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M)
          ((⨂[R]^na) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
        LinearMap.lflip)
      ((LinearMap.llcomp R ((⨂[R]^nc) M) ((⨂[R]^(nb + nc)) M) ((⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
          (LinearMap.flip (mul na (nb + nc))) ∘ₗ
        mul nb nc))
rhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((rhs a) b) c = GradedMonoid.GMul.mul a (GradedMonoid.GMul.mul b c)
⊢ (cast R M (_ : na + nb + nc = na + (nb + nc))) (GradedMonoid.GMul.mul (GradedMonoid.GMul.mul a b) c) =
    GradedMonoid.GMul.mul a (GradedMonoid.GMul.mul b c)

Next tactic:
suffices : lhs = rhs
theorem mul_assoc {na nb nc} (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M) :
    cast R M (add_assoc _ _ _) (a ₜ* b ₜ* c) = a ₜ* (b ₜ* c) := by
  let mul : ∀ n m : ℕ, (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M := fun n m =>
    (TensorProduct.mk R _ _).compr₂ ↑(mulEquiv : _ ≃ₗ[R] (⨂[R]^(n + m)) M)
  -- replace `a`, `b`, `c` with `tprod R a`, `tprod R b`, `tprod R c`
  let e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (add_assoc _ _ _)
  let lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ ((mul _ nc).compr₂ e.toLinearMap)).comp (mul na nb)
  have lhs_eq : ∀ a b c, lhs a b c = e (a ₜ* b ₜ* c) := fun _ _ _ => rfl
  let rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ (LinearMap.lflip (R := R)) <|
        (LinearMap.llcomp R _ _ _ (mul na _).flip).comp (mul nb nc)).flip
  have rhs_eq : ∀ a b c, rhs a b c = a ₜ* (b ₜ* c) := fun _ _ _ => rfl
  suffices : lhs = rhs
  exact LinearMap.congr_fun (LinearMap.congr_fun (LinearMap.congr_fun this a) b) c
  

Proof state:
case this
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
na nb nc : ℕ
a : (⨂[R]^na) M
b : (⨂[R]^nb) M
c : (⨂[R]^nc) M
mul : (n m : ℕ) → (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M :=
  fun n m => LinearMap.compr₂ (TensorProduct.mk R ((⨂[R]^n) M) ((⨂[R]^m) M)) ↑mulEquiv
e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (_ : na + nb + nc = na + (nb + nc))
lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  (LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^(na + nb)) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
      (LinearMap.compr₂ (mul (na + nb) nc) ↑e) ∘ₗ
    mul na nb
lhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((lhs a) b) c = e (GradedMonoid.GMul.mul (GradedMonoid.GMul.mul a b) c)
rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  LinearMap.flip
    (((LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M)
          ((⨂[R]^na) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
        LinearMap.lflip)
      ((LinearMap.llcomp R ((⨂[R]^nc) M) ((⨂[R]^(nb + nc)) M) ((⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
          (LinearMap.flip (mul na (nb + nc))) ∘ₗ
        mul nb nc))
rhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((rhs a) b) c = GradedMonoid.GMul.mul a (GradedMonoid.GMul.mul b c)
⊢ lhs = rhs

Next tactic:
ext a b c
theorem mul_assoc {na nb nc} (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M) :
    cast R M (add_assoc _ _ _) (a ₜ* b ₜ* c) = a ₜ* (b ₜ* c) := by
  let mul : ∀ n m : ℕ, (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M := fun n m =>
    (TensorProduct.mk R _ _).compr₂ ↑(mulEquiv : _ ≃ₗ[R] (⨂[R]^(n + m)) M)
  -- replace `a`, `b`, `c` with `tprod R a`, `tprod R b`, `tprod R c`
  let e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (add_assoc _ _ _)
  let lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ ((mul _ nc).compr₂ e.toLinearMap)).comp (mul na nb)
  have lhs_eq : ∀ a b c, lhs a b c = e (a ₜ* b ₜ* c) := fun _ _ _ => rfl
  let rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ (LinearMap.lflip (R := R)) <|
        (LinearMap.llcomp R _ _ _ (mul na _).flip).comp (mul nb nc)).flip
  have rhs_eq : ∀ a b c, rhs a b c = a ₜ* (b ₜ* c) := fun _ _ _ => rfl
  suffices : lhs = rhs
  exact LinearMap.congr_fun (LinearMap.congr_fun (LinearMap.congr_fun this a) b) c
  ext a b c
  -- clean up
  

Proof state:
case this.H.H.H.H.H.H
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
na nb nc : ℕ
a✝ : (⨂[R]^na) M
b✝ : (⨂[R]^nb) M
c✝ : (⨂[R]^nc) M
mul : (n m : ℕ) → (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M :=
  fun n m => LinearMap.compr₂ (TensorProduct.mk R ((⨂[R]^n) M) ((⨂[R]^m) M)) ↑mulEquiv
e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (_ : na + nb + nc = na + (nb + nc))
lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  (LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^(na + nb)) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
      (LinearMap.compr₂ (mul (na + nb) nc) ↑e) ∘ₗ
    mul na nb
lhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((lhs a) b) c = e (GradedMonoid.GMul.mul (GradedMonoid.GMul.mul a b) c)
rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  LinearMap.flip
    (((LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M)
          ((⨂[R]^na) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
        LinearMap.lflip)
      ((LinearMap.llcomp R ((⨂[R]^nc) M) ((⨂[R]^(nb + nc)) M) ((⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
          (LinearMap.flip (mul na (nb + nc))) ∘ₗ
        mul nb nc))
rhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((rhs a) b) c = GradedMonoid.GMul.mul a (GradedMonoid.GMul.mul b c)
a : Fin na → M
b : Fin nb → M
c : Fin nc → M
⊢ (LinearMap.compMultilinearMap
        ((LinearMap.compMultilinearMap ((LinearMap.compMultilinearMap lhs (tprod R)) a) (tprod R)) b) (tprod R))
      c =
    (LinearMap.compMultilinearMap
        ((LinearMap.compMultilinearMap ((LinearMap.compMultilinearMap rhs (tprod R)) a) (tprod R)) b) (tprod R))
      c

Next tactic:
simp only [LinearMap.compMultilinearMap_apply, lhs_eq, rhs_eq, tprod_mul_tprod, cast_tprod]
theorem mul_assoc {na nb nc} (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M) :
    cast R M (add_assoc _ _ _) (a ₜ* b ₜ* c) = a ₜ* (b ₜ* c) := by
  let mul : ∀ n m : ℕ, (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M := fun n m =>
    (TensorProduct.mk R _ _).compr₂ ↑(mulEquiv : _ ≃ₗ[R] (⨂[R]^(n + m)) M)
  -- replace `a`, `b`, `c` with `tprod R a`, `tprod R b`, `tprod R c`
  let e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (add_assoc _ _ _)
  let lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ ((mul _ nc).compr₂ e.toLinearMap)).comp (mul na nb)
  have lhs_eq : ∀ a b c, lhs a b c = e (a ₜ* b ₜ* c) := fun _ _ _ => rfl
  let rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ (LinearMap.lflip (R := R)) <|
        (LinearMap.llcomp R _ _ _ (mul na _).flip).comp (mul nb nc)).flip
  have rhs_eq : ∀ a b c, rhs a b c = a ₜ* (b ₜ* c) := fun _ _ _ => rfl
  suffices : lhs = rhs
  exact LinearMap.congr_fun (LinearMap.congr_fun (LinearMap.congr_fun this a) b) c
  ext a b c
  -- clean up
  simp only [LinearMap.compMultilinearMap_apply, lhs_eq, rhs_eq, tprod_mul_tprod, cast_tprod]
  

Proof state:
case this.H.H.H.H.H.H
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
na nb nc : ℕ
a✝ : (⨂[R]^na) M
b✝ : (⨂[R]^nb) M
c✝ : (⨂[R]^nc) M
mul : (n m : ℕ) → (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M :=
  fun n m => LinearMap.compr₂ (TensorProduct.mk R ((⨂[R]^n) M) ((⨂[R]^m) M)) ↑mulEquiv
e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (_ : na + nb + nc = na + (nb + nc))
lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  (LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^(na + nb)) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
      (LinearMap.compr₂ (mul (na + nb) nc) ↑e) ∘ₗ
    mul na nb
lhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((lhs a) b) c = e (GradedMonoid.GMul.mul (GradedMonoid.GMul.mul a b) c)
rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  LinearMap.flip
    (((LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M)
          ((⨂[R]^na) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
        LinearMap.lflip)
      ((LinearMap.llcomp R ((⨂[R]^nc) M) ((⨂[R]^(nb + nc)) M) ((⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
          (LinearMap.flip (mul na (nb + nc))) ∘ₗ
        mul nb nc))
rhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((rhs a) b) c = GradedMonoid.GMul.mul a (GradedMonoid.GMul.mul b c)
a : Fin na → M
b : Fin nb → M
c : Fin nc → M
⊢ (tprod R) (Fin.append (Fin.append a b) c ∘ Fin.cast (_ : na + (nb + nc) = na + nb + nc)) =
    (tprod R) (Fin.append a (Fin.append b c))

Next tactic:
congr with j
theorem mul_assoc {na nb nc} (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M) :
    cast R M (add_assoc _ _ _) (a ₜ* b ₜ* c) = a ₜ* (b ₜ* c) := by
  let mul : ∀ n m : ℕ, (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M := fun n m =>
    (TensorProduct.mk R _ _).compr₂ ↑(mulEquiv : _ ≃ₗ[R] (⨂[R]^(n + m)) M)
  -- replace `a`, `b`, `c` with `tprod R a`, `tprod R b`, `tprod R c`
  let e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (add_assoc _ _ _)
  let lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ ((mul _ nc).compr₂ e.toLinearMap)).comp (mul na nb)
  have lhs_eq : ∀ a b c, lhs a b c = e (a ₜ* b ₜ* c) := fun _ _ _ => rfl
  let rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ (LinearMap.lflip (R := R)) <|
        (LinearMap.llcomp R _ _ _ (mul na _).flip).comp (mul nb nc)).flip
  have rhs_eq : ∀ a b c, rhs a b c = a ₜ* (b ₜ* c) := fun _ _ _ => rfl
  suffices : lhs = rhs
  exact LinearMap.congr_fun (LinearMap.congr_fun (LinearMap.congr_fun this a) b) c
  ext a b c
  -- clean up
  simp only [LinearMap.compMultilinearMap_apply, lhs_eq, rhs_eq, tprod_mul_tprod, cast_tprod]
  congr with j
  

Proof state:
case this.H.H.H.H.H.H.h.e_6.h.h
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
na nb nc : ℕ
a✝ : (⨂[R]^na) M
b✝ : (⨂[R]^nb) M
c✝ : (⨂[R]^nc) M
mul : (n m : ℕ) → (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M :=
  fun n m => LinearMap.compr₂ (TensorProduct.mk R ((⨂[R]^n) M) ((⨂[R]^m) M)) ↑mulEquiv
e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (_ : na + nb + nc = na + (nb + nc))
lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  (LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^(na + nb)) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
      (LinearMap.compr₂ (mul (na + nb) nc) ↑e) ∘ₗ
    mul na nb
lhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((lhs a) b) c = e (GradedMonoid.GMul.mul (GradedMonoid.GMul.mul a b) c)
rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  LinearMap.flip
    (((LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M)
          ((⨂[R]^na) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
        LinearMap.lflip)
      ((LinearMap.llcomp R ((⨂[R]^nc) M) ((⨂[R]^(nb + nc)) M) ((⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
          (LinearMap.flip (mul na (nb + nc))) ∘ₗ
        mul nb nc))
rhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((rhs a) b) c = GradedMonoid.GMul.mul a (GradedMonoid.GMul.mul b c)
a : Fin na → M
b : Fin nb → M
c : Fin nc → M
j : Fin (na + (nb + nc))
⊢ (Fin.append (Fin.append a b) c ∘ Fin.cast (_ : na + (nb + nc) = na + nb + nc)) j = Fin.append a (Fin.append b c) j

Next tactic:
rw [Fin.append_assoc]
theorem mul_assoc {na nb nc} (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M) :
    cast R M (add_assoc _ _ _) (a ₜ* b ₜ* c) = a ₜ* (b ₜ* c) := by
  let mul : ∀ n m : ℕ, (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M := fun n m =>
    (TensorProduct.mk R _ _).compr₂ ↑(mulEquiv : _ ≃ₗ[R] (⨂[R]^(n + m)) M)
  -- replace `a`, `b`, `c` with `tprod R a`, `tprod R b`, `tprod R c`
  let e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (add_assoc _ _ _)
  let lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ ((mul _ nc).compr₂ e.toLinearMap)).comp (mul na nb)
  have lhs_eq : ∀ a b c, lhs a b c = e (a ₜ* b ₜ* c) := fun _ _ _ => rfl
  let rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ (LinearMap.lflip (R := R)) <|
        (LinearMap.llcomp R _ _ _ (mul na _).flip).comp (mul nb nc)).flip
  have rhs_eq : ∀ a b c, rhs a b c = a ₜ* (b ₜ* c) := fun _ _ _ => rfl
  suffices : lhs = rhs
  exact LinearMap.congr_fun (LinearMap.congr_fun (LinearMap.congr_fun this a) b) c
  ext a b c
  -- clean up
  simp only [LinearMap.compMultilinearMap_apply, lhs_eq, rhs_eq, tprod_mul_tprod, cast_tprod]
  congr with j
  rw [Fin.append_assoc]
  

Proof state:
case this.H.H.H.H.H.H.h.e_6.h.h
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
na nb nc : ℕ
a✝ : (⨂[R]^na) M
b✝ : (⨂[R]^nb) M
c✝ : (⨂[R]^nc) M
mul : (n m : ℕ) → (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M :=
  fun n m => LinearMap.compr₂ (TensorProduct.mk R ((⨂[R]^n) M) ((⨂[R]^m) M)) ↑mulEquiv
e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (_ : na + nb + nc = na + (nb + nc))
lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  (LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^(na + nb)) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
      (LinearMap.compr₂ (mul (na + nb) nc) ↑e) ∘ₗ
    mul na nb
lhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((lhs a) b) c = e (GradedMonoid.GMul.mul (GradedMonoid.GMul.mul a b) c)
rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  LinearMap.flip
    (((LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M)
          ((⨂[R]^na) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
        LinearMap.lflip)
      ((LinearMap.llcomp R ((⨂[R]^nc) M) ((⨂[R]^(nb + nc)) M) ((⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
          (LinearMap.flip (mul na (nb + nc))) ∘ₗ
        mul nb nc))
rhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((rhs a) b) c = GradedMonoid.GMul.mul a (GradedMonoid.GMul.mul b c)
a : Fin na → M
b : Fin nb → M
c : Fin nc → M
j : Fin (na + (nb + nc))
⊢ ((Fin.append a (Fin.append b c) ∘ Fin.cast (_ : na + nb + nc = na + (nb + nc))) ∘
        Fin.cast (_ : na + (nb + nc) = na + nb + nc))
      j =
    Fin.append a (Fin.append b c) j

Next tactic:
refine' congr_arg (Fin.append a (Fin.append b c)) (Fin.ext _)
theorem mul_assoc {na nb nc} (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M) :
    cast R M (add_assoc _ _ _) (a ₜ* b ₜ* c) = a ₜ* (b ₜ* c) := by
  let mul : ∀ n m : ℕ, (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M := fun n m =>
    (TensorProduct.mk R _ _).compr₂ ↑(mulEquiv : _ ≃ₗ[R] (⨂[R]^(n + m)) M)
  -- replace `a`, `b`, `c` with `tprod R a`, `tprod R b`, `tprod R c`
  let e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (add_assoc _ _ _)
  let lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ ((mul _ nc).compr₂ e.toLinearMap)).comp (mul na nb)
  have lhs_eq : ∀ a b c, lhs a b c = e (a ₜ* b ₜ* c) := fun _ _ _ => rfl
  let rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
    (LinearMap.llcomp R _ _ _ (LinearMap.lflip (R := R)) <|
        (LinearMap.llcomp R _ _ _ (mul na _).flip).comp (mul nb nc)).flip
  have rhs_eq : ∀ a b c, rhs a b c = a ₜ* (b ₜ* c) := fun _ _ _ => rfl
  suffices : lhs = rhs
  exact LinearMap.congr_fun (LinearMap.congr_fun (LinearMap.congr_fun this a) b) c
  ext a b c
  -- clean up
  simp only [LinearMap.compMultilinearMap_apply, lhs_eq, rhs_eq, tprod_mul_tprod, cast_tprod]
  congr with j
  rw [Fin.append_assoc]
  refine' congr_arg (Fin.append a (Fin.append b c)) (Fin.ext _)
  

Proof state:
case this.H.H.H.H.H.H.h.e_6.h.h
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
na nb nc : ℕ
a✝ : (⨂[R]^na) M
b✝ : (⨂[R]^nb) M
c✝ : (⨂[R]^nc) M
mul : (n m : ℕ) → (⨂[R]^n) M →ₗ[R] (⨂[R]^m) M →ₗ[R] (⨂[R]^(n + m)) M :=
  fun n m => LinearMap.compr₂ (TensorProduct.mk R ((⨂[R]^n) M) ((⨂[R]^m) M)) ↑mulEquiv
e : (⨂[R]^(na + nb + nc)) M ≃ₗ[R] (⨂[R]^(na + (nb + nc))) M := cast R M (_ : na + nb + nc = na + (nb + nc))
lhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  (LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^(na + nb)) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
      (LinearMap.compr₂ (mul (na + nb) nc) ↑e) ∘ₗ
    mul na nb
lhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((lhs a) b) c = e (GradedMonoid.GMul.mul (GradedMonoid.GMul.mul a b) c)
rhs : (⨂[R]^na) M →ₗ[R] (⨂[R]^nb) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M :=
  LinearMap.flip
    (((LinearMap.llcomp R ((⨂[R]^nb) M) ((⨂[R]^nc) M →ₗ[R] (⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M)
          ((⨂[R]^na) M →ₗ[R] (⨂[R]^nc) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
        LinearMap.lflip)
      ((LinearMap.llcomp R ((⨂[R]^nc) M) ((⨂[R]^(nb + nc)) M) ((⨂[R]^na) M →ₗ[R] (⨂[R]^(na + (nb + nc))) M))
          (LinearMap.flip (mul na (nb + nc))) ∘ₗ
        mul nb nc))
rhs_eq :
  ∀ (a : (⨂[R]^na) M) (b : (⨂[R]^nb) M) (c : (⨂[R]^nc) M),
    ((rhs a) b) c = GradedMonoid.GMul.mul a (GradedMonoid.GMul.mul b c)
a : Fin na → M
b : Fin nb → M
c : Fin nc → M
j : Fin (na + (nb + nc))
⊢ ↑(Fin.cast (_ : na + nb + nc = na + (nb + nc)) (Fin.cast (_ : na + (nb + nc) = na + nb + nc) j)) = ↑j

Next tactic:
rw [Fin.coe_cast, Fin.coe_cast]
theorem algebraMap₀_eq_smul_one (r : R) : (algebraMap₀ r : (⨂[R]^0) M) = r • ₜ1 := by
  

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
⊢ algebraMap₀ r = r • GradedMonoid.GOne.one

Next tactic:
simp [algebraMap₀]
theorem algebraMap₀_eq_smul_one (r : R) : (algebraMap₀ r : (⨂[R]^0) M) = r • ₜ1 := by
  simp [algebraMap₀]; 

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
⊢ r • (tprod R) isEmptyElim = r • GradedMonoid.GOne.one

Next tactic:
congr
theorem algebraMap₀_mul {n} (r : R) (a : (⨂[R]^n) M) :
    cast R M (zero_add _) (algebraMap₀ r ₜ* a) = r • a := by
  

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
n : ℕ
r : R
a : (⨂[R]^n) M
⊢ (cast R M (_ : 0 + n = n)) (GradedMonoid.GMul.mul (algebraMap₀ r) a) = r • a

Next tactic:
rw [gMul_eq_coe_linearMap, algebraMap₀_eq_smul_one, LinearMap.map_smul₂,
    LinearEquiv.map_smul, ← gMul_eq_coe_linearMap, one_mul]
theorem mul_algebraMap₀ {n} (r : R) (a : (⨂[R]^n) M) :
    cast R M (add_zero _) (a ₜ* algebraMap₀ r) = r • a := by
  

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
n : ℕ
r : R
a : (⨂[R]^n) M
⊢ (cast R M (_ : n + 0 = n)) (GradedMonoid.GMul.mul a (algebraMap₀ r)) = r • a

Next tactic:
rw [gMul_eq_coe_linearMap, algebraMap₀_eq_smul_one, LinearMap.map_smul,
    LinearEquiv.map_smul, ← gMul_eq_coe_linearMap, mul_one]
theorem algebraMap₀_mul_algebraMap₀ (r s : R) :
    cast R M (add_zero _) (algebraMap₀ r ₜ* algebraMap₀ s) = algebraMap₀ (r * s) := by
  

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r s : R
⊢ (cast R M (_ : 0 + 0 = 0)) (GradedMonoid.GMul.mul (algebraMap₀ r) (algebraMap₀ s)) = algebraMap₀ (r * s)

Next tactic:
rw [← smul_eq_mul, LinearEquiv.map_smul]
theorem algebraMap₀_mul_algebraMap₀ (r s : R) :
    cast R M (add_zero _) (algebraMap₀ r ₜ* algebraMap₀ s) = algebraMap₀ (r * s) := by
  rw [← smul_eq_mul, LinearEquiv.map_smul]
  

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r s : R
⊢ (cast R M (_ : 0 + 0 = 0)) (GradedMonoid.GMul.mul (algebraMap₀ r) (algebraMap₀ s)) = r • algebraMap₀ s

Next tactic:
exact algebraMap₀_mul r (@algebraMap₀ R M _ _ _ s)
instance gsemiring : DirectSum.GSemiring fun i => (⨂[R]^i) M :=
  { TensorPower.gmonoid with
    mul_zero := fun a => LinearMap.map_zero _
    zero_mul := fun b => LinearMap.map_zero₂ _ _
    mul_add := fun a b₁ b₂ => LinearMap.map_add _ _ _
    add_mul := fun a₁ a₂ b => LinearMap.map_add₂ _ _ _ _
    natCast := fun n => algebraMap₀ (n : R)
    natCast_zero := by 

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
src✝ : GradedMonoid.GMonoid fun i => (⨂[R]^i) M := gmonoid
⊢ (fun n => algebraMap₀ ↑n) 0 = 0

Next tactic:
simp only [Nat.cast_zero, map_zero]
instance gsemiring : DirectSum.GSemiring fun i => (⨂[R]^i) M :=
  { TensorPower.gmonoid with
    mul_zero := fun a => LinearMap.map_zero _
    zero_mul := fun b => LinearMap.map_zero₂ _ _
    mul_add := fun a b₁ b₂ => LinearMap.map_add _ _ _
    add_mul := fun a₁ a₂ b => LinearMap.map_add₂ _ _ _ _
    natCast := fun n => algebraMap₀ (n : R)
    natCast_zero := by simp only [Nat.cast_zero, map_zero]
    natCast_succ := fun n => by 

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
src✝ : GradedMonoid.GMonoid fun i => (⨂[R]^i) M := gmonoid
n : ℕ
⊢ (fun n => algebraMap₀ ↑n) (n + 1) = (fun n => algebraMap₀ ↑n) n + GradedMonoid.GOne.one

Next tactic:
simp only [Nat.cast_succ, map_add, algebraMap₀_one]