/-
Copyright (c) 2022 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa

! This file was ported from Lean 3 source module algebra.monoid_algebra.support
! leanprover-community/mathlib commit 69c6a5a12d8a2b159f20933e60115a4f2de62b58
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Algebra.MonoidAlgebra.Basic

/-!
#  Lemmas about the support of a finitely supported function

> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
-/

universe u₁ u₂ u₃

namespace MonoidAlgebra

open Finset Finsupp

variable {k : Type u₁} {G : Type u₂} [Semiring k]

/- warning: monoid_algebra.support_single_mul_subset -> MonoidAlgebra.support_single_mul_subset is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : DecidableEq.{succ u2} G] [_inst_3 : Mul.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) (r : k) (a : G), HasSubset.Subset.{u2} (Finset.{u2} G) (Finset.hasSubset.{u2} G) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 _inst_3)) (Finsupp.single.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) a r) f)) (Finset.image.{u2, u2} G G (fun (a : G) (b : G) => _inst_2 a b) (HMul.hMul.{u2, u2, u2} G G G (instHMul.{u2} G _inst_3) a) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : DecidableEq.{succ u2} G] [_inst_3 : Mul.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) (r : k) (a : G), HasSubset.Subset.{u2} (Finset.{u2} G) (Finset.instHasSubsetFinset.{u2} G) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 _inst_3)) (MonoidAlgebra.single.{u1, u2} k G _inst_1 a r) f)) (Finset.image.{u2, u2} G G (fun (a : G) (b : G) => _inst_2 a b) ((fun (x._@.Mathlib.Algebra.MonoidAlgebra.Support._hyg.55 : G) (x._@.Mathlib.Algebra.MonoidAlgebra.Support._hyg.57 : G) => HMul.hMul.{u2, u2, u2} G G G (instHMul.{u2} G _inst_3) x._@.Mathlib.Algebra.MonoidAlgebra.Support._hyg.55 x._@.Mathlib.Algebra.MonoidAlgebra.Support._hyg.57) a) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f))
Case conversion may be inaccurate. Consider using '#align monoid_algebra.support_single_mul_subset MonoidAlgebra.support_single_mul_subsetₓ'. -/
theorem support_single_mul_subset [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) (r : k) (a : G) :
    (single a r * f : MonoidAlgebra k G).support ⊆ Finset.image ((· * ·) a) f.support :=
  by
  intro x hx
  contrapose hx
  have : ∀ y, a * y = x → f y = 0 := by
    simpa only [not_and', mem_image, mem_support_iff, exists_prop, not_exists,
      Classical.not_not] using hx
  simp only [mem_support_iff, mul_apply, sum_single_index, MulZeroClass.zero_mul, if_t_t, sum_zero,
    Classical.not_not]
  exact
    Finset.sum_eq_zero
      (by
        simp (config := { contextual := true }) only [this, mem_support_iff, MulZeroClass.mul_zero,
          Ne.def, ite_eq_right_iff, eq_self_iff_true, imp_true_iff])
#align monoid_algebra.support_single_mul_subset MonoidAlgebra.support_single_mul_subset

/- warning: monoid_algebra.support_mul_single_subset -> MonoidAlgebra.support_mul_single_subset is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : DecidableEq.{succ u2} G] [_inst_3 : Mul.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) (r : k) (a : G), HasSubset.Subset.{u2} (Finset.{u2} G) (Finset.hasSubset.{u2} G) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 _inst_3)) f (Finsupp.single.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) a r))) (Finset.image.{u2, u2} G G (fun (a : G) (b : G) => _inst_2 a b) (fun (_x : G) => HMul.hMul.{u2, u2, u2} G G G (instHMul.{u2} G _inst_3) _x a) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : DecidableEq.{succ u2} G] [_inst_3 : Mul.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) (r : k) (a : G), HasSubset.Subset.{u2} (Finset.{u2} G) (Finset.instHasSubsetFinset.{u2} G) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 _inst_3)) f (MonoidAlgebra.single.{u1, u2} k G _inst_1 a r))) (Finset.image.{u2, u2} G G (fun (a : G) (b : G) => _inst_2 a b) (fun (_x : G) => HMul.hMul.{u2, u2, u2} G G G (instHMul.{u2} G _inst_3) _x a) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f))
Case conversion may be inaccurate. Consider using '#align monoid_algebra.support_mul_single_subset MonoidAlgebra.support_mul_single_subsetₓ'. -/
theorem support_mul_single_subset [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) (r : k) (a : G) :
    (f * single a r).support ⊆ Finset.image (· * a) f.support :=
  by
  intro x hx
  contrapose hx
  have : ∀ y, y * a = x → f y = 0 := by
    simpa only [not_and', mem_image, mem_support_iff, exists_prop, not_exists,
      Classical.not_not] using hx
  simp only [mem_support_iff, mul_apply, sum_single_index, MulZeroClass.zero_mul, if_t_t, sum_zero,
    Classical.not_not]
  exact
    Finset.sum_eq_zero
      (by
        simp (config := { contextual := true }) only [this, sum_single_index, ite_eq_right_iff,
          eq_self_iff_true, imp_true_iff, MulZeroClass.zero_mul])
#align monoid_algebra.support_mul_single_subset MonoidAlgebra.support_mul_single_subset

/- warning: monoid_algebra.support_single_mul_eq_image -> MonoidAlgebra.support_single_mul_eq_image is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : DecidableEq.{succ u2} G] [_inst_3 : Mul.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) {r : k}, (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (Distrib.toHasMul.{u1} k (NonUnitalNonAssocSemiring.toDistrib.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))) r y) (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))))))) -> (forall {x : G}, (IsLeftRegular.{u2} G _inst_3 x) -> (Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 _inst_3)) (Finsupp.single.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) x r) f)) (Finset.image.{u2, u2} G G (fun (a : G) (b : G) => _inst_2 a b) (HMul.hMul.{u2, u2, u2} G G G (instHMul.{u2} G _inst_3) x) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f))))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : DecidableEq.{succ u2} G] [_inst_3 : Mul.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) {r : k}, (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (NonUnitalNonAssocSemiring.toMul.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) r y) (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)))))) -> (forall {x : G}, (IsLeftRegular.{u2} G _inst_3 x) -> (Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 _inst_3)) (MonoidAlgebra.single.{u1, u2} k G _inst_1 x r) f)) (Finset.image.{u2, u2} G G (fun (a : G) (b : G) => _inst_2 a b) ((fun (x._@.Mathlib.Algebra.MonoidAlgebra.Support._hyg.365 : G) (x._@.Mathlib.Algebra.MonoidAlgebra.Support._hyg.367 : G) => HMul.hMul.{u2, u2, u2} G G G (instHMul.{u2} G _inst_3) x._@.Mathlib.Algebra.MonoidAlgebra.Support._hyg.365 x._@.Mathlib.Algebra.MonoidAlgebra.Support._hyg.367) x) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f))))
Case conversion may be inaccurate. Consider using '#align monoid_algebra.support_single_mul_eq_image MonoidAlgebra.support_single_mul_eq_imageₓ'. -/
theorem support_single_mul_eq_image [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) {r : k}
    (hr : ∀ y, r * y = 0 ↔ y = 0) {x : G} (lx : IsLeftRegular x) :
    (single x r * f : MonoidAlgebra k G).support = Finset.image ((· * ·) x) f.support :=
  by
  refine' subset_antisymm (support_single_mul_subset f _ _) fun y hy => _
  obtain ⟨y, yf, rfl⟩ : ∃ a : G, a ∈ f.support ∧ x * a = y := by
    simpa only [Finset.mem_image, exists_prop] using hy
  simp only [mul_apply, mem_support_iff.mp yf, hr, mem_support_iff, sum_single_index,
    Finsupp.sum_ite_eq', Ne.def, not_false_iff, if_true, MulZeroClass.zero_mul, if_t_t, sum_zero,
    lx.eq_iff]
#align monoid_algebra.support_single_mul_eq_image MonoidAlgebra.support_single_mul_eq_image

/- warning: monoid_algebra.support_mul_single_eq_image -> MonoidAlgebra.support_mul_single_eq_image is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : DecidableEq.{succ u2} G] [_inst_3 : Mul.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) {r : k}, (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (Distrib.toHasMul.{u1} k (NonUnitalNonAssocSemiring.toDistrib.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))) y r) (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))))))) -> (forall {x : G}, (IsRightRegular.{u2} G _inst_3 x) -> (Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 _inst_3)) f (Finsupp.single.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) x r))) (Finset.image.{u2, u2} G G (fun (a : G) (b : G) => _inst_2 a b) (fun (_x : G) => HMul.hMul.{u2, u2, u2} G G G (instHMul.{u2} G _inst_3) _x x) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f))))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : DecidableEq.{succ u2} G] [_inst_3 : Mul.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) {r : k}, (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (NonUnitalNonAssocSemiring.toMul.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) y r) (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)))))) -> (forall {x : G}, (IsRightRegular.{u2} G _inst_3 x) -> (Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 _inst_3)) f (MonoidAlgebra.single.{u1, u2} k G _inst_1 x r))) (Finset.image.{u2, u2} G G (fun (a : G) (b : G) => _inst_2 a b) (fun (_x : G) => HMul.hMul.{u2, u2, u2} G G G (instHMul.{u2} G _inst_3) _x x) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f))))
Case conversion may be inaccurate. Consider using '#align monoid_algebra.support_mul_single_eq_image MonoidAlgebra.support_mul_single_eq_imageₓ'. -/
theorem support_mul_single_eq_image [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) {r : k}
    (hr : ∀ y, y * r = 0 ↔ y = 0) {x : G} (rx : IsRightRegular x) :
    (f * single x r).support = Finset.image (· * x) f.support :=
  by
  refine' subset_antisymm (support_mul_single_subset f _ _) fun y hy => _
  obtain ⟨y, yf, rfl⟩ : ∃ a : G, a ∈ f.support ∧ a * x = y := by
    simpa only [Finset.mem_image, exists_prop] using hy
  simp only [mul_apply, mem_support_iff.mp yf, hr, mem_support_iff, sum_single_index,
    Finsupp.sum_ite_eq', Ne.def, not_false_iff, if_true, MulZeroClass.mul_zero, if_t_t, sum_zero,
    rx.eq_iff]
#align monoid_algebra.support_mul_single_eq_image MonoidAlgebra.support_mul_single_eq_image

#print MonoidAlgebra.support_mul /-
theorem support_mul [Mul G] [DecidableEq G] (a b : MonoidAlgebra k G) :
    (a * b).support ⊆ a.support.bunionᵢ fun a₁ => b.support.bunionᵢ fun a₂ => {a₁ * a₂} :=
  Subset.trans support_sum <|
    bunionᵢ_mono fun a₁ _ =>
      Subset.trans support_sum <| bunionᵢ_mono fun a₂ _ => support_single_subset
#align monoid_algebra.support_mul MonoidAlgebra.support_mul
-/

/- warning: monoid_algebra.support_mul_single -> MonoidAlgebra.support_mul_single is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : RightCancelSemigroup.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) (r : k), (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (Distrib.toHasMul.{u1} k (NonUnitalNonAssocSemiring.toDistrib.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))) y r) (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))))))) -> (forall (x : G), Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 (Semigroup.toHasMul.{u2} G (RightCancelSemigroup.toSemigroup.{u2} G _inst_2)))) f (Finsupp.single.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) x r))) (Finset.map.{u2, u2} G G (mulRightEmbedding.{u2} G _inst_2 x) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f)))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : RightCancelSemigroup.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) (r : k), (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (NonUnitalNonAssocSemiring.toMul.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) y r) (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)))))) -> (forall (x : G), Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 (Semigroup.toMul.{u2} G (RightCancelSemigroup.toSemigroup.{u2} G _inst_2)))) f (MonoidAlgebra.single.{u1, u2} k G _inst_1 x r))) (Finset.map.{u2, u2} G G (mulRightEmbedding.{u2} G _inst_2 x) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f)))
Case conversion may be inaccurate. Consider using '#align monoid_algebra.support_mul_single MonoidAlgebra.support_mul_singleₓ'. -/
theorem support_mul_single [RightCancelSemigroup G] (f : MonoidAlgebra k G) (r : k)
    (hr : ∀ y, y * r = 0 ↔ y = 0) (x : G) :
    (f * single x r).support = f.support.map (mulRightEmbedding x) := by
  classical
    ext
    simp only [support_mul_single_eq_image f hr (isRightRegular_of_rightCancelSemigroup x),
      mem_image, mem_map, mulRightEmbedding_apply]
#align monoid_algebra.support_mul_single MonoidAlgebra.support_mul_single

/- warning: monoid_algebra.support_single_mul -> MonoidAlgebra.support_single_mul is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : LeftCancelSemigroup.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) (r : k), (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (Distrib.toHasMul.{u1} k (NonUnitalNonAssocSemiring.toDistrib.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))) r y) (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))))))) -> (forall (x : G), Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 (Semigroup.toHasMul.{u2} G (LeftCancelSemigroup.toSemigroup.{u2} G _inst_2)))) (Finsupp.single.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) x r) f)) (Finset.map.{u2, u2} G G (mulLeftEmbedding.{u2} G _inst_2 x) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f)))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : LeftCancelSemigroup.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1) (r : k), (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (NonUnitalNonAssocSemiring.toMul.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) r y) (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)))))) -> (forall (x : G), Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.mul.{u1, u2} k G _inst_1 (Semigroup.toMul.{u2} G (LeftCancelSemigroup.toSemigroup.{u2} G _inst_2)))) (MonoidAlgebra.single.{u1, u2} k G _inst_1 x r) f)) (Finset.map.{u2, u2} G G (mulLeftEmbedding.{u2} G _inst_2 x) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f)))
Case conversion may be inaccurate. Consider using '#align monoid_algebra.support_single_mul MonoidAlgebra.support_single_mulₓ'. -/
theorem support_single_mul [LeftCancelSemigroup G] (f : MonoidAlgebra k G) (r : k)
    (hr : ∀ y, r * y = 0 ↔ y = 0) (x : G) :
    (single x r * f : MonoidAlgebra k G).support = f.support.map (mulLeftEmbedding x) := by
  classical
    ext
    simp only [support_single_mul_eq_image f hr (isLeftRegular_of_leftCancelSemigroup x), mem_image,
      mem_map, mulLeftEmbedding_apply]
#align monoid_algebra.support_single_mul MonoidAlgebra.support_single_mul

section Span

variable [MulOneClass G]

/- warning: monoid_algebra.mem_span_support -> MonoidAlgebra.mem_span_support is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : MulOneClass.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1), Membership.Mem.{max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.{u1, max u1 u2} k (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (MonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (MonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (SetLike.hasMem.{max u1 u2, max u1 u2} (Submodule.{u1, max u1 u2} k (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (MonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (MonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (MonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.setLike.{u1, max u1 u2} k (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (MonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (MonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)))) f (Submodule.span.{u1, max u1 u2} k (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (MonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (MonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)) (Set.image.{u2, max u1 u2} G (MonoidAlgebra.{u1, u2} k G _inst_1) (coeFn.{max (succ (max u1 u2)) (succ u2), max (succ u2) (succ (max u1 u2))} (MonoidHom.{u2, max u1 u2} G (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_2 (MulZeroOneClass.toMulOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) (fun (_x : MonoidHom.{u2, max u1 u2} G (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_2 (MulZeroOneClass.toMulOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) => G -> (MonoidAlgebra.{u1, u2} k G _inst_1)) (MonoidHom.hasCoeToFun.{u2, max u1 u2} G (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_2 (MulZeroOneClass.toMulOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) (MonoidAlgebra.of.{u1, u2} k G _inst_1 _inst_2)) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} G) (Set.{u2} G) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} G) (Set.{u2} G) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} G) (Set.{u2} G) (Finset.Set.hasCoeT.{u2} G))) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f))))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : MulOneClass.{u2} G] (f : MonoidAlgebra.{u1, u2} k G _inst_1), Membership.mem.{max u1 u2, max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.{u1, max u1 u2} k (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (MonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (MonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (SetLike.instMembership.{max u1 u2, max u1 u2} (Submodule.{u1, max u1 u2} k (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (MonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (MonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (MonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.setLike.{u1, max u1 u2} k (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (MonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (MonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)))) f (Submodule.span.{u1, max u1 u2} k (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (MonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (MonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)) (Set.image.{u2, max u1 u2} G (MonoidAlgebra.{u1, u2} k G _inst_1) (FunLike.coe.{max (succ u1) (succ u2), succ u2, max (succ u1) (succ u2)} (MonoidHom.{u2, max u2 u1} G (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_2 (MulZeroOneClass.toMulOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => MonoidAlgebra.{u1, u2} k G _inst_1) _x) (MulHomClass.toFunLike.{max u1 u2, u2, max u1 u2} (MonoidHom.{u2, max u2 u1} G (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_2 (MulZeroOneClass.toMulOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) G (MonoidAlgebra.{u1, u2} k G _inst_1) (MulOneClass.toMul.{u2} G _inst_2) (MulOneClass.toMul.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroOneClass.toMulOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u2, max u1 u2} (MonoidHom.{u2, max u2 u1} G (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_2 (MulZeroOneClass.toMulOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) G (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_2 (MulZeroOneClass.toMulOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2))) (MonoidHom.monoidHomClass.{u2, max u1 u2} G (MonoidAlgebra.{u1, u2} k G _inst_1) _inst_2 (MulZeroOneClass.toMulOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (MonoidAlgebra.{u1, u2} k G _inst_1) (MonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))))) (MonoidAlgebra.of.{u1, u2} k G _inst_1 _inst_2)) (Finset.toSet.{u2} G (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f))))
Case conversion may be inaccurate. Consider using '#align monoid_algebra.mem_span_support MonoidAlgebra.mem_span_supportₓ'. -/
/-- An element of `monoid_algebra k G` is in the subalgebra generated by its support. -/
theorem mem_span_support (f : MonoidAlgebra k G) :
    f ∈ Submodule.span k (of k G '' (f.support : Set G)) := by
  rw [of, MonoidHom.coe_mk, ← Finsupp.supported_eq_span_single, Finsupp.mem_supported]
#align monoid_algebra.mem_span_support MonoidAlgebra.mem_span_support

end Span

end MonoidAlgebra

namespace AddMonoidAlgebra

open Finset Finsupp MulOpposite

variable {k : Type u₁} {G : Type u₂} [Semiring k]

#print AddMonoidAlgebra.support_mul /-
theorem support_mul [DecidableEq G] [Add G] (a b : AddMonoidAlgebra k G) :
    (a * b).support ⊆ a.support.bunionᵢ fun a₁ => b.support.bunionᵢ fun a₂ => {a₁ + a₂} :=
  @MonoidAlgebra.support_mul k (Multiplicative G) _ _ _ _ _
#align add_monoid_algebra.support_mul AddMonoidAlgebra.support_mul
-/

/- warning: add_monoid_algebra.support_mul_single -> AddMonoidAlgebra.support_mul_single is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddRightCancelSemigroup.{u2} G] (f : AddMonoidAlgebra.{u1, u2} k G _inst_1) (r : k), (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (Distrib.toHasMul.{u1} k (NonUnitalNonAssocSemiring.toDistrib.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))) y r) (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))))))) -> (forall (x : G), Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.hasMul.{u1, u2} k G _inst_1 (AddSemigroup.toHasAdd.{u2} G (AddRightCancelSemigroup.toAddSemigroup.{u2} G _inst_2)))) f (Finsupp.single.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) x r))) (Finset.map.{u2, u2} G G (addRightEmbedding.{u2} G _inst_2 x) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f)))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddRightCancelSemigroup.{u2} G] (f : AddMonoidAlgebra.{u1, u2} k G _inst_1) (r : k), (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (NonUnitalNonAssocSemiring.toMul.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) y r) (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)))))) -> (forall (x : G), Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.hasMul.{u1, u2} k G _inst_1 (AddSemigroup.toAdd.{u2} G (AddRightCancelSemigroup.toAddSemigroup.{u2} G _inst_2)))) f (AddMonoidAlgebra.single.{u1, u2} k G _inst_1 x r))) (Finset.map.{u2, u2} G G (addRightEmbedding.{u2} G _inst_2 x) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f)))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.support_mul_single AddMonoidAlgebra.support_mul_singleₓ'. -/
theorem support_mul_single [AddRightCancelSemigroup G] (f : AddMonoidAlgebra k G) (r : k)
    (hr : ∀ y, y * r = 0 ↔ y = 0) (x : G) :
    (f * single x r : AddMonoidAlgebra k G).support = f.support.map (addRightEmbedding x) :=
  @MonoidAlgebra.support_mul_single k (Multiplicative G) _ _ _ _ hr _
#align add_monoid_algebra.support_mul_single AddMonoidAlgebra.support_mul_single

/- warning: add_monoid_algebra.support_single_mul -> AddMonoidAlgebra.support_single_mul is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddLeftCancelSemigroup.{u2} G] (f : AddMonoidAlgebra.{u1, u2} k G _inst_1) (r : k), (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (Distrib.toHasMul.{u1} k (NonUnitalNonAssocSemiring.toDistrib.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))) r y) (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))))))) -> (forall (x : G), Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.hasMul.{u1, u2} k G _inst_1 (AddSemigroup.toHasAdd.{u2} G (AddLeftCancelSemigroup.toAddSemigroup.{u2} G _inst_2)))) (Finsupp.single.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) x r) f)) (Finset.map.{u2, u2} G G (addLeftEmbedding.{u2} G _inst_2 x) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f)))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddLeftCancelSemigroup.{u2} G] (f : AddMonoidAlgebra.{u1, u2} k G _inst_1) (r : k), (forall (y : k), Iff (Eq.{succ u1} k (HMul.hMul.{u1, u1, u1} k k k (instHMul.{u1} k (NonUnitalNonAssocSemiring.toMul.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) r y) (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1))))) (Eq.{succ u1} k y (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)))))) -> (forall (x : G), Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.hasMul.{u1, u2} k G _inst_1 (AddSemigroup.toAdd.{u2} G (AddLeftCancelSemigroup.toAddSemigroup.{u2} G _inst_2)))) (AddMonoidAlgebra.single.{u1, u2} k G _inst_1 x r) f)) (Finset.map.{u2, u2} G G (addLeftEmbedding.{u2} G _inst_2 x) (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f)))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.support_single_mul AddMonoidAlgebra.support_single_mulₓ'. -/
theorem support_single_mul [AddLeftCancelSemigroup G] (f : AddMonoidAlgebra k G) (r : k)
    (hr : ∀ y, r * y = 0 ↔ y = 0) (x : G) :
    (single x r * f : AddMonoidAlgebra k G).support = f.support.map (addLeftEmbedding x) :=
  @MonoidAlgebra.support_single_mul k (Multiplicative G) _ _ _ _ hr _
#align add_monoid_algebra.support_single_mul AddMonoidAlgebra.support_single_mul

section Span

/- warning: add_monoid_algebra.mem_span_support -> AddMonoidAlgebra.mem_span_support is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddZeroClass.{u2} G] (f : AddMonoidAlgebra.{u1, u2} k G _inst_1), Membership.Mem.{max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.{u1, max u2 u1} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (SetLike.hasMem.{max u2 u1, max u2 u1} (Submodule.{u1, max u2 u1} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.setLike.{u1, max u2 u1} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)))) f (Submodule.span.{u1, max u2 u1} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)) (Set.image.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (coeFn.{max (succ (max u2 u1)) (succ u2), max (succ u2) (succ (max u2 u1))} (MonoidHom.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Multiplicative.mulOneClass.{u2} G _inst_2) (MulZeroOneClass.toMulOneClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) (fun (_x : MonoidHom.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Multiplicative.mulOneClass.{u2} G _inst_2) (MulZeroOneClass.toMulOneClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) => (Multiplicative.{u2} G) -> (AddMonoidAlgebra.{u1, u2} k G _inst_1)) (MonoidHom.hasCoeToFun.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Multiplicative.mulOneClass.{u2} G _inst_2) (MulZeroOneClass.toMulOneClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) (AddMonoidAlgebra.of.{u1, u2} k G _inst_1 _inst_2)) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} G) (Set.{u2} G) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} G) (Set.{u2} G) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} G) (Set.{u2} G) (Finset.Set.hasCoeT.{u2} G))) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f))))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddZeroClass.{u2} G] (f : AddMonoidAlgebra.{u1, u2} k G _inst_1), Membership.mem.{max u1 u2, max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.{u1, max u1 u2} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (SetLike.instMembership.{max u1 u2, max u1 u2} (Submodule.{u1, max u1 u2} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.setLike.{u1, max u1 u2} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)))) f (Submodule.span.{u1, max u1 u2} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)) (Set.image.{u2, max u1 u2} (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (FunLike.coe.{max (succ u1) (succ u2), succ u2, max (succ u1) (succ u2)} (MonoidHom.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Multiplicative.mulOneClass.{u2} G _inst_2) (MulZeroOneClass.toMulOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) (Multiplicative.{u2} G) (fun (_x : Multiplicative.{u2} G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Multiplicative.{u2} G) => AddMonoidAlgebra.{u1, u2} k G _inst_1) _x) (MulHomClass.toFunLike.{max u1 u2, u2, max u1 u2} (MonoidHom.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Multiplicative.mulOneClass.{u2} G _inst_2) (MulZeroOneClass.toMulOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulOneClass.toMul.{u2} (Multiplicative.{u2} G) (Multiplicative.mulOneClass.{u2} G _inst_2)) (MulOneClass.toMul.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroOneClass.toMulOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u2, max u1 u2} (MonoidHom.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Multiplicative.mulOneClass.{u2} G _inst_2) (MulZeroOneClass.toMulOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))) (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Multiplicative.mulOneClass.{u2} G _inst_2) (MulZeroOneClass.toMulOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2))) (MonoidHom.monoidHomClass.{u2, max u1 u2} (Multiplicative.{u2} G) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Multiplicative.mulOneClass.{u2} G _inst_2) (MulZeroOneClass.toMulOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 _inst_2)))))) (AddMonoidAlgebra.of.{u1, u2} k G _inst_1 _inst_2)) (Finset.toSet.{u2} G (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.mem_span_support AddMonoidAlgebra.mem_span_supportₓ'. -/
/-- An element of `add_monoid_algebra k G` is in the submodule generated by its support. -/
theorem mem_span_support [AddZeroClass G] (f : AddMonoidAlgebra k G) :
    f ∈ Submodule.span k (of k G '' (f.support : Set G)) := by
  rw [of, MonoidHom.coe_mk, ← Finsupp.supported_eq_span_single, Finsupp.mem_supported]
#align add_monoid_algebra.mem_span_support AddMonoidAlgebra.mem_span_support

/- warning: add_monoid_algebra.mem_span_support' -> AddMonoidAlgebra.mem_span_support' is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] (f : AddMonoidAlgebra.{u1, u2} k G _inst_1), Membership.Mem.{max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.{u1, max u2 u1} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (SetLike.hasMem.{max u2 u1, max u2 u1} (Submodule.{u1, max u2 u1} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.setLike.{u1, max u2 u1} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)))) f (Submodule.span.{u1, max u2 u1} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)) (Set.image.{u2, max u2 u1} G (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} G) (Set.{u2} G) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} G) (Set.{u2} G) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} G) (Set.{u2} G) (Finset.Set.hasCoeT.{u2} G))) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) f))))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] (f : AddMonoidAlgebra.{u1, u2} k G _inst_1), Membership.mem.{max u1 u2, max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.{u1, max u1 u2} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (SetLike.instMembership.{max u1 u2, max u1 u2} (Submodule.{u1, max u1 u2} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1))) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Submodule.setLike.{u1, max u1 u2} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)))) f (Submodule.span.{u1, max u1 u2} k (AddMonoidAlgebra.{u1, u2} k G _inst_1) _inst_1 (AddMonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1) (AddMonoidAlgebra.module.{u1, u2, u1} k G k _inst_1 _inst_1 (Semiring.toModule.{u1} k _inst_1)) (Set.image.{u2, max u1 u2} G (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1) (Finset.toSet.{u2} G (Finsupp.support.{u2, u1} G k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k _inst_1)) f))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.mem_span_support' AddMonoidAlgebra.mem_span_support'ₓ'. -/
/-- An element of `add_monoid_algebra k G` is in the subalgebra generated by its support, using
unbundled inclusion. -/
theorem mem_span_support' (f : AddMonoidAlgebra k G) :
    f ∈ Submodule.span k (of' k G '' (f.support : Set G)) := by
  rw [of', ← Finsupp.supported_eq_span_single, Finsupp.mem_supported]
#align add_monoid_algebra.mem_span_support' AddMonoidAlgebra.mem_span_support'

end Span

end AddMonoidAlgebra


/-
Copyright (c) 2021 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca, Johan Commelin
-/
import analysis.normed.group.SemiNormedGroup
import category_theory.preadditive.additive_functor
import analysis.normed.group.hom_completion

/-!
# Completions of normed groups

This file contains an API for completions of seminormed groups (basic facts about
objects and morphisms).

## Main definitions

- `SemiNormedGroup.Completion : SemiNormedGroup ⥤ SemiNormedGroup` : the completion of a
  seminormed group (defined as a functor on `SemiNormedGroup` to itself).
- `SemiNormedGroup.Completion.lift (f : V ⟶ W) : (Completion.obj V ⟶ W)` : a normed group hom
  from `V` to complete `W` extends ("lifts") to a seminormed group hom from the completion of
  `V` to `W`.

## Projects

1. Construct the category of complete seminormed groups, say `CompleteSemiNormedGroup`
  and promote the `Completion` functor below to a functor landing in this category.
2. Prove that the functor `Completion : SemiNormedGroup ⥤ CompleteSemiNormedGroup`
  is left adjoint to the forgetful functor.

-/

noncomputable theory

universe u

open uniform_space mul_opposite category_theory normed_add_group_hom

namespace SemiNormedGroup

/-- The completion of a seminormed group, as an endofunctor on `SemiNormedGroup`. -/
@[simps]
def Completion : SemiNormedGroup.{u} ⥤ SemiNormedGroup.{u} :=
{ obj := λ V, SemiNormedGroup.of (completion V),
  map := λ V W f, f.completion,
  map_id' := λ V, completion_id,
  map_comp' := λ U V W f g, (completion_comp f g).symm }

instance Completion_complete_space {V : SemiNormedGroup} : complete_space (Completion.obj V) :=
completion.complete_space _

/-- The canonical morphism from a seminormed group `V` to its completion. -/
@[simps]
def Completion.incl {V : SemiNormedGroup} : V ⟶ Completion.obj V :=
{ to_fun := λ v, (v : completion V),
  map_add' := completion.coe_add,
  bound' := ⟨1, λ v, by simp⟩ }

lemma Completion.norm_incl_eq {V : SemiNormedGroup} {v : V} : ‖Completion.incl v‖ = ‖v‖ := by simp

/-- Given a normed group hom `V ⟶ W`, this defines the associated morphism
from the completion of `V` to the completion of `W`.
The difference from the definition obtained from the functoriality of completion is in that the
map sending a morphism `f` to the associated morphism of completions is itself additive. -/
def Completion.map_hom (V W : SemiNormedGroup.{u}) :
  (V ⟶ W) →+ (Completion.obj V ⟶ Completion.obj W) :=
add_monoid_hom.mk' (category_theory.functor.map Completion) $ λ f g,
  f.completion_add g

@[simp] lemma Completion.map_zero (V W : SemiNormedGroup) : Completion.map (0 : V ⟶ W) = 0 :=
(Completion.map_hom V W).map_zero

instance : preadditive SemiNormedGroup.{u} :=
{ hom_group := λ P Q, infer_instance,
  add_comp' := by { intros, ext,
    simp only [normed_add_group_hom.add_apply, category_theory.comp_apply, map_add] },
  comp_add' := by { intros, ext,
    simp only [normed_add_group_hom.add_apply, category_theory.comp_apply, map_add] } }

instance : functor.additive Completion :=
{ map_add' := λ X Y, (Completion.map_hom _ _).map_add }

/-- Given a normed group hom `f : V → W` with `W` complete, this provides a lift of `f` to
the completion of `V`. The lemmas `lift_unique` and `lift_comp_incl` provide the api for the
universal property of the completion. -/
def Completion.lift {V W : SemiNormedGroup} [complete_space W] [separated_space W] (f : V ⟶ W) :
  Completion.obj V ⟶ W :=
{ to_fun := f.extension,
  map_add' := f.extension.to_add_monoid_hom.map_add',
  bound' := f.extension.bound' }

lemma Completion.lift_comp_incl {V W : SemiNormedGroup} [complete_space W] [separated_space W]
  (f : V ⟶ W) : Completion.incl ≫ (Completion.lift f) = f :=
by { ext, apply normed_add_group_hom.extension_coe }

lemma Completion.lift_unique {V W : SemiNormedGroup} [complete_space W] [separated_space W]
  (f : V ⟶ W) (g : Completion.obj V ⟶ W) : Completion.incl ≫ g = f → g = Completion.lift f :=
λ h, (normed_add_group_hom.extension_unique _ (λ v, ((ext_iff.1 h) v).symm)).symm

end SemiNormedGroup


/- 9 Sep 2019 -/

-- characteristic vector for set membership
-- cardinality of power set of set with n elements is 2^n
-- number of k-subsets of [n]
-- binomial theorem
-- permutations
-- theorem stating that every permutation can be written uniquely as a product of disjoint cycles
-- fixed point


/-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.category_theory.limits.shapes.terminal
import Mathlib.category_theory.limits.shapes.binary_products
import Mathlib.PostPort

universes v₁ u₁

namespace Mathlib

/-!
# Subterminal objects

Subterminal objects are the objects which can be thought of as subobjects of the terminal object.
In fact, the definition can be constructed to not require a terminal object, by defining `A` to be
subterminal iff for any `Z`, there is at most one morphism `Z ⟶ A`.
An alternate definition is that the diagonal morphism `A ⟶ A ⨯ A` is an isomorphism.
In this file we define subterminal objects and show the equivalence of these three definitions.

We also construct the subcategory of subterminal objects.

## TODO

* Define exponential ideals, and show this subcategory is an exponential ideal.
* Define subobject lattices in general, show that `subterminals C` is equivalent to the subobject
category of a terminal object.
* Use both the above to show that in a locally cartesian closed category, every subobject lattice
  is cartesian closed (equivalently, a Heyting algebra).

-/

namespace category_theory

/-- An object `A` is subterminal iff for any `Z`, there is at most one morphism `Z ⟶ A`. -/
def is_subterminal {C : Type u₁} [category C] (A : C) :=
  ∀ {Z : C} (f g : Z ⟶ A), f = g

theorem is_subterminal.def {C : Type u₁} [category C] {A : C} : is_subterminal A ↔ ∀ {Z : C} (f g : Z ⟶ A), f = g :=
  iff.rfl

/--
If `A` is subterminal, the unique morphism from it to a terminal object is a monomorphism.
The converse of `is_subterminal_of_mono_is_terminal_from`.
-/
theorem is_subterminal.mono_is_terminal_from {C : Type u₁} [category C] {A : C} (hA : is_subterminal A) {T : C} (hT : limits.is_terminal T) : mono (limits.is_terminal.from hT A) :=
  mono.mk fun (Z : C) (g h : Z ⟶ A) (_x : g ≫ limits.is_terminal.from hT A = h ≫ limits.is_terminal.from hT A) => hA g h

/--
If `A` is subterminal, the unique morphism from it to the terminal object is a monomorphism.
The converse of `is_subterminal_of_mono_terminal_from`.
-/
theorem is_subterminal.mono_terminal_from {C : Type u₁} [category C] {A : C} [limits.has_terminal C] (hA : is_subterminal A) : mono (limits.terminal.from A) :=
  is_subterminal.mono_is_terminal_from hA limits.terminal_is_terminal

/--
If the unique morphism from `A` to a terminal object is a monomorphism, `A` is subterminal.
The converse of `is_subterminal.mono_is_terminal_from`.
-/
theorem is_subterminal_of_mono_is_terminal_from {C : Type u₁} [category C] {A : C} {T : C} (hT : limits.is_terminal T) [mono (limits.is_terminal.from hT A)] : is_subterminal A :=
  fun (Z : C) (f g : Z ⟶ A) =>
    eq.mpr (id (Eq._oldrec (Eq.refl (f = g)) (Eq.symm (propext (cancel_mono (limits.is_terminal.from hT A))))))
      (limits.is_terminal.hom_ext hT (f ≫ limits.is_terminal.from hT A) (g ≫ limits.is_terminal.from hT A))

/--
If the unique morphism from `A` to the terminal object is a monomorphism, `A` is subterminal.
The converse of `is_subterminal.mono_terminal_from`.
-/
theorem is_subterminal_of_mono_terminal_from {C : Type u₁} [category C] {A : C} [limits.has_terminal C] [mono (limits.terminal.from A)] : is_subterminal A :=
  fun (Z : C) (f g : Z ⟶ A) =>
    eq.mpr (id (Eq._oldrec (Eq.refl (f = g)) (Eq.symm (propext (cancel_mono (limits.terminal.from A))))))
      (subsingleton.elim (f ≫ limits.terminal.from A) (g ≫ limits.terminal.from A))

theorem is_subterminal_of_is_terminal {C : Type u₁} [category C] {T : C} (hT : limits.is_terminal T) : is_subterminal T :=
  fun (Z : C) (f g : Z ⟶ T) => limits.is_terminal.hom_ext hT f g

theorem is_subterminal_of_terminal {C : Type u₁} [category C] [limits.has_terminal C] : is_subterminal (⊤_C) :=
  fun (Z : C) (f g : Z ⟶ ⊤_C) => subsingleton.elim f g

/--
If `A` is subterminal, its diagonal morphism is an isomorphism.
The converse of `is_subterminal_of_is_iso_diag`.
-/
def is_subterminal.is_iso_diag {C : Type u₁} [category C] {A : C} (hA : is_subterminal A) [limits.has_binary_product A A] : is_iso (limits.diag A) :=
  is_iso.mk limits.prod.fst

/--
If the diagonal morphism of `A` is an isomorphism, then it is subterminal.
The converse of `is_subterminal.is_iso_diag`.
-/
theorem is_subterminal_of_is_iso_diag {C : Type u₁} [category C] {A : C} [limits.has_binary_product A A] [is_iso (limits.diag A)] : is_subterminal A := sorry

/-- If `A` is subterminal, it is isomorphic to `A ⨯ A`. -/
@[simp] theorem is_subterminal.iso_diag_hom {C : Type u₁} [category C] {A : C} (hA : is_subterminal A) [limits.has_binary_product A A] : iso.hom (is_subterminal.iso_diag hA) = inv (limits.diag A) :=
  Eq.refl (inv (limits.diag A))

/--
The (full sub)category of subterminal objects.
TODO: If `C` is the category of sheaves on a topological space `X`, this category is equivalent
to the lattice of open subsets of `X`. More generally, if `C` is a topos, this is the lattice of
"external truth values".
-/
def subterminals (C : Type u₁) [category C] :=
  Subtype fun (A : C) => is_subterminal A

protected instance subterminals.inhabited (C : Type u₁) [category C] [limits.has_terminal C] : Inhabited (subterminals C) :=
  { default := { val := ⊤_C, property := is_subterminal_of_terminal } }

/-- The inclusion of the subterminal objects into the original category. -/
def subterminal_inclusion (C : Type u₁) [category C] : subterminals C ⥤ C :=
  full_subcategory_inclusion fun (A : C) => is_subterminal A


import ring_theory.algebra

namespace mv_polynomial

/-- evaluation of a polynomial over R in an R-algebra is an R-algebra morphism-/
noncomputable def alg_eval
  {R : Type*} [comm_ring R] {A : Type*} [comm_ring A] [algebra R A] {σ : Type*}
  (f : σ → A) : mv_polynomial σ R →ₐ[R] A :=
{ commutes' := λ _, eval₂_C _ _ _,
  ..ring_hom.of (eval₂ (algebra_map A : R → A) f)
}

/-- An R-algebra homomorphism f : R[X_1, X_2, ...] → A
is determined by the evaluations f(X_1), f(X_2), ... -/
@[simp] lemma alg_eval_hom_X
  {R : Type*} [comm_ring R] {A : Type*} [comm_ring A] [algebra R A] {σ : Type*}
--{σ : Type*} (c : ℤ → β) [is_ring_hom c]
  (f : mv_polynomial σ R →ₐ[R] A) (x : mv_polynomial σ R) :
  eval₂ (algebra_map A) (f ∘ X) x = f x :=
mv_polynomial.induction_on x
(λ r, by rw eval₂_C; exact (f.commutes r).symm)
(λ p q hp hq, by { rw [eval₂_add, hp, hq], exact (is_ring_hom.map_add f).symm })
(λ p n hp, by { rw [eval₂_mul, eval₂_X, hp], exact (is_ring_hom.map_mul f).symm })

/-- If A is an R-algebra, then to give an R-algebra homomorphism
f : R[X_i : i ∈ σ] → A is to give a map σ → A -/
noncomputable def alg_hom_equiv
  {R : Type*} [comm_ring R] {A : Type*} [comm_ring A] [algebra R A] {σ : Type} :
  (mv_polynomial σ R →ₐ[R] A) ≃ (σ → A) :=
{ to_fun := λ f, ⇑f ∘ X,
  inv_fun := alg_eval,
  left_inv := λ _, alg_hom.ext $ alg_eval_hom_X _,
  right_inv := λ _, funext $ λ _, eval₂_X _ _ _,
}

end mv_polynomial

-- quotients

namespace alg_hom

open function

theorem ext_iff {R : Type*} [comm_ring R]
  {A : Type*} [comm_ring A] [algebra R A]
  {B : Type*} [comm_ring B] [algebra R B] (φ ψ : A →ₐ[R] B) :
  φ = ψ ↔ ∀ a : A, φ a = ψ a :=
⟨λ h a, by rw h, alg_hom.ext⟩

noncomputable def quot.lift
  {R : Type*} [comm_ring R]
  {A : Type*} [comm_ring A] [algebra R A]
  {B : Type*} [comm_ring B] [algebra R B]
  {C : Type*} [comm_ring C] [algebra R C]
  (f : A →ₐ[R] B) (hf : surjective f)
  (g : A →ₐ[R] C) (hfg : ∀ a : A, f a = 0 → g a = 0) :
  B →ₐ[R] C :=
{ to_fun := λ b, g (classical.some (hf b)),
  map_one' := begin
    change _ = (1 : C),
    rw [←g.map_one, ←sub_eq_zero_iff_eq, ←g.map_sub],
    apply hfg,
    rw [f.map_sub, sub_eq_zero_iff_eq, f.map_one],
    exact classical.some_spec (hf 1),
  end,
  map_mul' := begin
    intros b₁ b₂,
    show _ = _ * _,
    rw [←g.map_mul, ←sub_eq_zero_iff_eq, ←g.map_sub],
    apply hfg,
    rw [f.map_sub, sub_eq_zero_iff_eq, f.map_mul],
    rw [classical.some_spec (hf b₁), classical.some_spec (hf b₂)],
    exact classical.some_spec (hf (b₁ * b₂))
  end,
  map_zero' := begin
    change _ = (0 : C),
    apply hfg,
    exact classical.some_spec (hf 0),
  end,
  map_add' := begin
    intros b₁ b₂,
    show _ = _ + _,
    rw [←g.map_add, ←sub_eq_zero_iff_eq, ←g.map_sub],
    apply hfg,
    rw [f.map_sub, sub_eq_zero_iff_eq, f.map_add],
    rw [classical.some_spec (hf b₁), classical.some_spec (hf b₂)],
    exact classical.some_spec (hf (b₁ + b₂))
  end,
  commutes' := begin
    intros r,
    rw [←g.commutes, ←sub_eq_zero_iff_eq, ←g.map_sub],
    apply hfg,
    rw [f.map_sub, sub_eq_zero_iff_eq, f.commutes, classical.some_spec (hf (algebra_map B r))]
  end
}

theorem quot.thm
  {R : Type*} [comm_ring R]
  {A : Type*} [comm_ring A] [algebra R A]
  {B : Type*} [comm_ring B] [algebra R B]
  {C : Type*} [comm_ring C] [algebra R C]
  (f : A →ₐ[R] B) (hf : surjective f)
  (g : A →ₐ[R] C) (hfg : ∀ a : A, f a = 0 → g a = 0) :
  alg_hom.comp (quot.lift f hf g hfg) f = g :=
begin
  ext a,
  show g _ = g a,
  rw [←sub_eq_zero_iff_eq, ←g.map_sub],
  apply hfg,
  rw [f.map_sub, sub_eq_zero_iff_eq],
  exact classical.some_spec (hf _),
end

theorem quot.thm'
  {R : Type*} [comm_ring R]
  {A : Type*} [comm_ring A] [algebra R A]
  {B : Type*} [comm_ring B] [algebra R B]
  {C : Type*} [comm_ring C] [algebra R C]
  (f : A →ₐ[R] B) (hf : surjective f)
  (g : A →ₐ[R] C) (hfg : ∀ a : A, f a = 0 → g a = 0) (a : A) :
  (quot.lift f hf g hfg) (f a) = g a :=
begin
  have xxx := quot.thm f hf g hfg,
  rw alg_hom.ext_iff at xxx,
  exact xxx a,
end

end alg_hom


/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.data.nat.basic
import Mathlib.algebra.ordered_group
import Mathlib.PostPort

namespace Mathlib

/-!
# `with_bot ℕ`

Lemmas about the type of natural numbers with a bottom element adjoined.
-/

namespace nat

theorem with_bot.add_eq_zero_iff {n : with_bot ℕ} {m : with_bot ℕ} : n + m = 0 ↔ n = 0 ∧ m = 0 := sorry

theorem with_bot.add_eq_one_iff {n : with_bot ℕ} {m : with_bot ℕ} : n + m = 1 ↔ n = 0 ∧ m = 1 ∨ n = 1 ∧ m = 0 := sorry

@[simp] theorem with_bot.coe_nonneg {n : ℕ} : 0 ≤ ↑n :=
  eq.mpr (id (Eq._oldrec (Eq.refl (0 ≤ ↑n)) (Eq.symm with_bot.coe_zero)))
    (eq.mpr (id (Eq._oldrec (Eq.refl (↑0 ≤ ↑n)) (propext with_bot.coe_le_coe))) (zero_le n))

@[simp] theorem with_bot.lt_zero_iff (n : with_bot ℕ) : n < 0 ↔ n = ⊥ := sorry