/-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca, Johan Commelin, Scott Morrison
-/
import analysis.normed.group.SemiNormedGroup
import analysis.normed.group.quotient
import category_theory.limits.shapes.kernels

/-!
# Kernels and cokernels in SemiNormedGroup₁ and SemiNormedGroup

We show that `SemiNormedGroup₁` has cokernels
(for which of course the `cokernel.π f` maps are norm non-increasing),
as well as the easier result that `SemiNormedGroup` has cokernels. We also show that
`SemiNormedGroup` has kernels.

So far, I don't see a way to state nicely what we really want:
`SemiNormedGroup` has cokernels, and `cokernel.π f` is norm non-increasing.
The problem is that the limits API doesn't promise you any particular model of the cokernel,
and in `SemiNormedGroup` one can always take a cokernel and rescale its norm
(and hence making `cokernel.π f` arbitrarily large in norm), obtaining another categorical cokernel.

-/

open category_theory category_theory.limits

universe u

namespace SemiNormedGroup₁

noncomputable theory

/-- Auxiliary definition for `has_cokernels SemiNormedGroup₁`. -/
def cokernel_cocone {X Y : SemiNormedGroup₁.{u}} (f : X ⟶ Y) : cofork f 0 :=
cofork.of_π
  (@SemiNormedGroup₁.mk_hom
    _ (SemiNormedGroup.of (Y ⧸ (normed_group_hom.range f.1)))
    f.1.range.normed_mk
    (normed_group_hom.is_quotient_quotient _).norm_le)
  begin
    ext,
    simp only [comp_apply, limits.zero_comp, normed_group_hom.zero_apply,
      SemiNormedGroup₁.mk_hom_apply, SemiNormedGroup₁.zero_apply, ←normed_group_hom.mem_ker,
      f.1.range.ker_normed_mk, f.1.mem_range],
    use x,
    refl,
  end

/-- Auxiliary definition for `has_cokernels SemiNormedGroup₁`. -/
def cokernel_lift {X Y : SemiNormedGroup₁.{u}} (f : X ⟶ Y) (s : cokernel_cofork f) :
  (cokernel_cocone f).X ⟶ s.X :=
begin
  fsplit,
  -- The lift itself:
  { apply normed_group_hom.lift _ s.π.1,
    rintro _ ⟨b, rfl⟩,
    change (f ≫ s.π) b = 0,
    simp, },
  -- The lift has norm at most one:
  exact normed_group_hom.lift_norm_noninc _ _ _ s.π.2,
end

instance : has_cokernels SemiNormedGroup₁.{u} :=
{ has_colimit := λ X Y f, has_colimit.mk
  { cocone := cokernel_cocone f,
    is_colimit := is_colimit_aux _
      (cokernel_lift f)
      (λ s, begin
        ext,
        apply normed_group_hom.lift_mk f.1.range,
        rintro _ ⟨b, rfl⟩,
        change (f ≫ s.π) b = 0,
        simp,
      end)
      (λ s m w, subtype.eq
        (normed_group_hom.lift_unique f.1.range _ _ _ (congr_arg subtype.val w : _))), } }

-- Sanity check
example : has_cokernels SemiNormedGroup₁ := by apply_instance

end SemiNormedGroup₁

namespace SemiNormedGroup

section equalizers_and_kernels

/-- The equalizer cone for a parallel pair of morphisms of seminormed groups. -/
def parallel_pair_cone {V W : SemiNormedGroup.{u}} (f g : V ⟶ W) :
  cone (parallel_pair f g) :=
@fork.of_ι _ _ _ _ _ _ (of (f - g).ker) (normed_group_hom.incl (f - g).ker) $
begin
  ext v,
  have : v.1 ∈ (f - g).ker := v.2,
  simpa only [normed_group_hom.incl_apply, pi.zero_apply, coe_comp, normed_group_hom.coe_zero,
    subtype.val_eq_coe, normed_group_hom.mem_ker,
    normed_group_hom.coe_sub, pi.sub_apply, sub_eq_zero] using this
end

instance has_limit_parallel_pair {V W : SemiNormedGroup.{u}} (f g : V ⟶ W) :
  has_limit (parallel_pair f g) :=
{ exists_limit := nonempty.intro
  { cone := parallel_pair_cone f g,
    is_limit := fork.is_limit.mk _
      (λ c, normed_group_hom.ker.lift (fork.ι c) _ $
      show normed_group_hom.comp_hom (f - g) c.ι = 0,
      by { rw [add_monoid_hom.map_sub, add_monoid_hom.sub_apply, sub_eq_zero], exact c.condition })
      (λ c, normed_group_hom.ker.incl_comp_lift _ _ _)
      (λ c g h, by { ext x, dsimp, rw ← h, refl }) } }

instance : limits.has_equalizers.{u (u+1)} SemiNormedGroup :=
@has_equalizers_of_has_limit_parallel_pair SemiNormedGroup _ $ λ V W f g,
  SemiNormedGroup.has_limit_parallel_pair f g

end equalizers_and_kernels

section cokernel

-- PROJECT: can we reuse the work to construct cokernels in `SemiNormedGroup₁` here?
-- I don't see a way to do this that is less work than just repeating the relevant parts.

/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/
def cokernel_cocone {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) : cofork f 0 :=
@cofork.of_π _ _ _ _ _ _
  (SemiNormedGroup.of (Y ⧸ (normed_group_hom.range f)))
  f.range.normed_mk
  begin
    ext,
    simp only [comp_apply, limits.zero_comp, normed_group_hom.zero_apply,
      ←normed_group_hom.mem_ker, f.range.ker_normed_mk, f.mem_range, exists_apply_eq_apply],
  end

/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/
def cokernel_lift {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) (s : cokernel_cofork f) :
  (cokernel_cocone f).X ⟶ s.X := normed_group_hom.lift _ s.π
begin
  rintro _ ⟨b, rfl⟩,
  change (f ≫ s.π) b = 0,
  simp,
end

/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/
def is_colimit_cokernel_cocone {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :
  is_colimit (cokernel_cocone f) :=
is_colimit_aux _ (cokernel_lift f)
(λ s, begin
  ext,
  apply normed_group_hom.lift_mk f.range,
  rintro _ ⟨b, rfl⟩,
  change (f ≫ s.π) b = 0,
  simp,
end)
(λ s m w, normed_group_hom.lift_unique f.range _ _ _ w)

instance : has_cokernels SemiNormedGroup.{u} :=
{ has_colimit := λ X Y f, has_colimit.mk
  { cocone := cokernel_cocone f,
    is_colimit := is_colimit_cokernel_cocone f } }

-- Sanity check
example : has_cokernels SemiNormedGroup := by apply_instance

section explicit_cokernel

/-- An explicit choice of cokernel, which has good properties with respect to the norm. -/
def explicit_cokernel {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) : SemiNormedGroup.{u} :=
(cokernel_cocone f).X

/-- Descend to the explicit cokernel. -/
def explicit_cokernel_desc {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}
  (w : f ≫ g = 0) : explicit_cokernel f ⟶ Z :=
(is_colimit_cokernel_cocone f).desc (cofork.of_π g (by simp [w]))

/-- The projection from `Y` to the explicit cokernel of `X ⟶ Y`. -/
def explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) : Y ⟶ explicit_cokernel f :=
(cokernel_cocone f).ι.app walking_parallel_pair.one

lemma explicit_cokernel_π_surjective {X Y : SemiNormedGroup.{u}} {f : X ⟶ Y} :
  function.surjective (explicit_cokernel_π f) :=
surjective_quot_mk _

@[simp, reassoc]
lemma comp_explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :
  f ≫ explicit_cokernel_π f = 0 :=
begin
  convert (cokernel_cocone f).w walking_parallel_pair_hom.left,
  simp,
end

@[simp]
lemma explicit_cokernel_π_apply_dom_eq_zero {X Y : SemiNormedGroup.{u}} {f : X ⟶ Y} (x : X) :
  (explicit_cokernel_π f) (f x) = 0 :=
show (f ≫ (explicit_cokernel_π f)) x = 0, by { rw [comp_explicit_cokernel_π], refl }

@[simp, reassoc]
lemma explicit_cokernel_π_desc {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}
  (w : f ≫ g = 0) : explicit_cokernel_π f ≫ explicit_cokernel_desc w = g :=
(is_colimit_cokernel_cocone f).fac _ _

@[simp]
lemma explicit_cokernel_π_desc_apply {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}
  {cond : f ≫ g = 0} (x : Y) : explicit_cokernel_desc cond (explicit_cokernel_π f x) = g x :=
show (explicit_cokernel_π f ≫ explicit_cokernel_desc cond) x = g x, by rw explicit_cokernel_π_desc

lemma explicit_cokernel_desc_unique {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}
  (w : f ≫ g = 0) (e : explicit_cokernel f ⟶ Z) (he : explicit_cokernel_π f ≫ e = g) :
  e = explicit_cokernel_desc w :=
begin
  apply (is_colimit_cokernel_cocone f).uniq (cofork.of_π g (by simp [w])),
  rintro (_|_),
  { convert w.symm,
    simp },
  { exact he }
end

lemma explicit_cokernel_desc_comp_eq_desc {X Y Z W : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}
  {h : Z ⟶ W} {cond : f ≫ g = 0} :
  explicit_cokernel_desc cond ≫ h = explicit_cokernel_desc (show f ≫ (g ≫ h) = 0,
  by rw [← category_theory.category.assoc, cond, limits.zero_comp]) :=
begin
  refine explicit_cokernel_desc_unique _ _ _,
  rw [← category_theory.category.assoc, explicit_cokernel_π_desc]
end

@[simp]
lemma explicit_cokernel_desc_zero {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} :
  explicit_cokernel_desc (show f ≫ (0 : Y ⟶ Z) = 0, from category_theory.limits.comp_zero) = 0 :=
eq.symm $ explicit_cokernel_desc_unique _ _ category_theory.limits.comp_zero

@[ext]
lemma explicit_cokernel_hom_ext {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y}
  (e₁ e₂ : explicit_cokernel f ⟶ Z)
  (h : explicit_cokernel_π f ≫ e₁ = explicit_cokernel_π f ≫ e₂) : e₁ = e₂ :=
begin
  let g : Y ⟶ Z := explicit_cokernel_π f ≫ e₂,
  have w : f ≫ g = 0, by simp,
  have : e₂ = explicit_cokernel_desc w,
  { apply explicit_cokernel_desc_unique, refl },
  rw this,
  apply explicit_cokernel_desc_unique,
  exact h,
end

instance explicit_cokernel_π.epi {X Y : SemiNormedGroup.{u}} {f : X ⟶ Y} :
  epi (explicit_cokernel_π f) :=
begin
  constructor,
  intros Z g h H,
  ext x,
  obtain ⟨x, hx⟩ := explicit_cokernel_π_surjective (explicit_cokernel_π f x),
  change (explicit_cokernel_π f ≫ g) _ = _,
  rw [H]
end

lemma is_quotient_explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :
normed_group_hom.is_quotient (explicit_cokernel_π f) :=
normed_group_hom.is_quotient_quotient _

lemma norm_noninc_explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :
  (explicit_cokernel_π f).norm_noninc :=
(is_quotient_explicit_cokernel_π f).norm_le

open_locale nnreal

lemma explicit_cokernel_desc_norm_le_of_norm_le {X Y Z : SemiNormedGroup.{u}}
  {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) (c : ℝ≥0) (h : ∥ g ∥ ≤ c) :
  ∥ explicit_cokernel_desc w ∥ ≤ c :=
normed_group_hom.lift_norm_le _ _ _ h

lemma explicit_cokernel_desc_comp_eq_zero {X Y Z W : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}
  {h : Z ⟶ W} (cond : f ≫ g = 0) (cond2 : g ≫ h = 0) :
  explicit_cokernel_desc cond ≫ h = 0 :=
begin
  rw [← cancel_epi (explicit_cokernel_π f), ← category.assoc, explicit_cokernel_π_desc],
  simp [cond2]
end

lemma explicit_cokernel_desc_norm_le {X Y Z : SemiNormedGroup.{u}}
  {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) : ∥ explicit_cokernel_desc w ∥ ≤ ∥ g ∥ :=
explicit_cokernel_desc_norm_le_of_norm_le w ∥ g ∥₊ (le_refl _)

/-- The explicit cokernel is isomorphic to the usual cokernel. -/
def explicit_cokernel_iso {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :
  explicit_cokernel f ≅ cokernel f :=
(is_colimit_cokernel_cocone f).cocone_point_unique_up_to_iso (colimit.is_colimit _)

@[simp]
lemma explicit_cokernel_iso_hom_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :
  explicit_cokernel_π f ≫ (explicit_cokernel_iso f).hom = cokernel.π _ :=
by simp [explicit_cokernel_π, explicit_cokernel_iso]

@[simp]
lemma explicit_cokernel_iso_inv_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :
  cokernel.π f ≫ (explicit_cokernel_iso f).inv = explicit_cokernel_π f :=
by simp [explicit_cokernel_π, explicit_cokernel_iso]

@[simp]
lemma explicit_cokernel_iso_hom_desc {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}
  (w : f ≫ g = 0) :
  (explicit_cokernel_iso f).hom ≫ cokernel.desc f g w = explicit_cokernel_desc w :=
begin
  ext1,
  simp [explicit_cokernel_desc, explicit_cokernel_π, explicit_cokernel_iso],
end

/-- A special case of `category_theory.limits.cokernel.map` adapted to `explicit_cokernel`. -/
noncomputable def explicit_cokernel.map {A B C D : SemiNormedGroup.{u}} {fab : A ⟶ B}
  {fbd : B ⟶ D} {fac : A ⟶ C} {fcd : C ⟶ D} (h : fab ≫ fbd = fac ≫ fcd) :
  explicit_cokernel fab ⟶ explicit_cokernel fcd :=
@explicit_cokernel_desc _ _ _ fab (fbd ≫ explicit_cokernel_π _) $ by simp [reassoc_of h]

/-- A special case of `category_theory.limits.cokernel.map_desc` adapted to `explicit_cokernel`. -/
lemma explicit_coker.map_desc {A B C D B' D' : SemiNormedGroup.{u}}
  {fab : A ⟶ B} {fbd : B ⟶ D} {fac : A ⟶ C} {fcd : C ⟶ D}
  {h : fab ≫ fbd = fac ≫ fcd} {fbb' : B ⟶ B'} {fdd' : D ⟶ D'}
  {condb : fab ≫ fbb' = 0} {condd : fcd ≫ fdd' = 0} {g : B' ⟶ D'}
  (h' : fbb' ≫ g = fbd ≫ fdd'):
  explicit_cokernel_desc condb ≫ g = explicit_cokernel.map h ≫ explicit_cokernel_desc condd :=
begin
  delta explicit_cokernel.map,
  simp [← cancel_epi (explicit_cokernel_π fab), category.assoc, explicit_cokernel_π_desc, h']
end

end explicit_cokernel

end cokernel

end SemiNormedGroup


import Err

/-! # `Res String α` example -/

namespace Err.Examples.String

abbrev Res :=
  Err.Res (Err.Err String String)
abbrev ErrStateT :=
  Err.ErrStateT String String
abbrev ErrStateM :=
  Err.ErrStateM String String

abbrev resOf (source : String) (trace : optParam (List String) []) : Res α :=
  ⟨source, trace⟩
  |> err

abbrev div? (a b : Nat) : Res Nat :=
  do
    if b = 0 then
      bail s!"cannot divide `{a}` by `{b}`"
    return a / b

example :
  div? 7 0 = resOf "cannot divide `7` by `0`"
:= rfl

abbrev divAddDiv? (a b c d : Nat) : Res Nat :=
  do
    let d₁ ←
      div? a b
      |>.withContext lazy_s!"cannot compute `{a}/{b} + {c}/{d}`"
    let d₂ ←
      div? c d
      |>.withContext lazy_s!"cannot compute `{a}/{b} + {c}/{d}"
    return d₁ + d₂

example :
  divAddDiv? 7 0 3 2
  =
  resOf "cannot divide `7` by `0`" ["cannot compute `7/0 + 3/2`"]
:= rfl

-- Don't know how to prove this :/

-- example :
--   divAddDiv? 7 2 3 0
--   =
--   resOf "cannot divide `3` by `0`" ["cannot compute `7/2 + 3/0`"]
-- := by
--   simp [
--     divAddDiv?, div?,
--     Res.withContext, Res.pure,
--     pure, bail, Err.context,
--     resOf, Err.mk
--   ]
--   rfl

abbrev ErrState.divAddDiv? (a b c d : Nat) : ErrStateM (Option Nat) :=
  do
    let d₁ ←
      div? a b
      |>.withContext
        lazy_s!"that's unexpected :/"
      |>.withContext
        lazy_s!"cannot compute `d₁` as `{a}/{b}`"
      |> ErrStateT.unwrap?

    let d₂ ←
      div? c d
      |>.withContext
        lazy_s!"that's unexpected :/"
      |>.withContext
        lazy_s!"cannot compute `d₂` as `{c}/{d}`"
      |> ErrStateT.unwrap?

    ErrStateT.withContext
      lazy_s!"while computing `d₁` and `d₂`"

    if let (some d₁, some d₂) := (d₁, d₂)
    then
      d₁ + d₂ |> some |> pure
    else
      ErrStateT.errgister
        "failed to compute d₁ and/or d₂, see below"
      ErrStateT.withContext
        lazy_s!"failed to compute `{a}/{b} + {c}/{d}`"
      ErrStateT.withContext
          lazy_s!"something went wrong `/(T_T)\\`"
      ErrStateT.finalizeWith
          lazy_s!"error during `divAddDiv?`"
      return none

#eval
  ErrState.divAddDiv? 3 0 7 0
  |>.run default
  |>.2

#eval
  ErrState.divAddDiv? 3 0 7 0
  |>.run default
  |>.2
  |> fun ⟨_, _, trees⟩ =>
    trees.head!.linearPrefixFoldl
    0
    (fun sum _ => sum + 1)
    (fun sum _ => sum)


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

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

/-!
# Division of `add_monoid_algebra` by monomials

This file is most important for when `G = ℕ` (polynomials) or `G = σ →₀ ℕ` (multivariate
polynomials).

In order to apply in maximal generality (such as for `laurent_polynomial`s), this uses
`∃ d, g' = g + d` in many places instead of `g ≤ g'`.

## Main definitions

* `add_monoid_algebra.div_of x g`: divides `x` by the monomial `add_monoid_algebra.of k G g`
* `add_monoid_algebra.mod_of x g`: the remainder upon dividing `x` by the monomial
  `add_monoid_algebra.of k G g`.

## Main results

* `add_monoid_algebra.div_of_add_mod_of`, `add_monoid_algebra.mod_of_add_div_of`: `div_of` and
  `mod_of` are well-behaved as quotient and remainder operators.

## Implementation notes

`∃ d, g' = g + d` is used as opposed to some other permutation up to commutativity in order to match
the definition of `semigroup_has_dvd`. The results in this file could be duplicated for
`monoid_algebra` by using `g ∣ g'`, but this can't be done automatically, and in any case is not
likely to be very useful.

-/

variable {k G : Type _} [Semiring k]

namespace AddMonoidAlgebra

section

variable [AddCancelCommMonoid G]

#print AddMonoidAlgebra.divOf /-
/-- Divide by `of' k G g`, discarding terms not divisible by this. -/
noncomputable def divOf (x : AddMonoidAlgebra k G) (g : G) : AddMonoidAlgebra k G :=
  -- note: comapping by `+ g` has the effect of subtracting `g` from every element in the support, and
    -- discarding the elements of the support from which `g` can't be subtracted. If `G` is an additive
    -- group, such as `ℤ` when used for `laurent_polynomial`, then no discarding occurs.
    @Finsupp.comapDomain.addMonoidHom
    _ _ _ _ ((· + ·) g) (add_right_injective g) x
#align add_monoid_algebra.div_of AddMonoidAlgebra.divOf
-/

-- mathport name: «expr /ᵒᶠ »
local infixl:70 " /ᵒᶠ " => divOf

/- warning: add_monoid_algebra.div_of_apply -> AddMonoidAlgebra.divOf_apply is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (g : G) (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g' : G), Eq.{succ u1} k (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x g) g') (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) x (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g g'))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (g : G) (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g' : G), Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x g) g') (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) x (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g g'))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.div_of_apply AddMonoidAlgebra.divOf_applyₓ'. -/
@[simp]
theorem divOf_apply (g : G) (x : AddMonoidAlgebra k G) (g' : G) : (x /ᵒᶠ g) g' = x (g + g') :=
  rfl
#align add_monoid_algebra.div_of_apply AddMonoidAlgebra.divOf_apply

/- warning: add_monoid_algebra.support_div_of -> AddMonoidAlgebra.support_divOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (g : G) (x : AddMonoidAlgebra.{u1, u2} k G _inst_1), 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)))) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x g)) (Finset.preimage.{u2, u2} G 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)))) x) (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g) (Function.Injective.injOn.{u2, u2} G G (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g) (add_right_injective.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))) (AddLeftCancelSemigroup.toIsLeftCancelAdd.{u2} G (AddLeftCancelMonoid.toAddLeftCancelSemigroup.{u2} G (AddCancelCommMonoid.toAddLeftCancelMonoid.{u2} G _inst_2))) g) (Set.preimage.{u2, u2} G G (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g) ((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)))) x)))))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (g : G) (x : AddMonoidAlgebra.{u2, u1} k G _inst_1), Eq.{succ u1} (Finset.{u1} G) (Finsupp.support.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1)) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x g)) (Finset.preimage.{u1, u1} G G (Finsupp.support.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1)) x) ((fun (x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.821 : G) (x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.823 : G) => HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.821 x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.823) g) (Function.Injective.injOn.{u1, u1} G G ((fun (x._@.Mathlib.Algebra.Group.Defs._hyg.2622 : G) (x._@.Mathlib.Algebra.Group.Defs._hyg.2624 : G) => HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) x._@.Mathlib.Algebra.Group.Defs._hyg.2622 x._@.Mathlib.Algebra.Group.Defs._hyg.2624) g) (add_right_injective.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))) (IsCancelAdd.toIsLeftCancelAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))) (AddCancelMonoid.toIsCancelAdd.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))) g) (Set.preimage.{u1, u1} G G ((fun (x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.821 : G) (x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.823 : G) => HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.821 x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.823) g) (Finset.toSet.{u1} G (Finsupp.support.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1)) x)))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.support_div_of AddMonoidAlgebra.support_divOfₓ'. -/
@[simp]
theorem support_divOf (g : G) (x : AddMonoidAlgebra k G) :
    (x /ᵒᶠ g).support =
      x.support.Preimage ((· + ·) g) (Function.Injective.injOn (add_right_injective g) _) :=
  rfl
#align add_monoid_algebra.support_div_of AddMonoidAlgebra.support_divOf

/- warning: add_monoid_algebra.zero_div_of -> AddMonoidAlgebra.zero_divOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))))) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))))) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.zero_div_of AddMonoidAlgebra.zero_divOfₓ'. -/
@[simp]
theorem zero_divOf (g : G) : (0 : AddMonoidAlgebra k G) /ᵒᶠ g = 0 :=
  map_zero _
#align add_monoid_algebra.zero_div_of AddMonoidAlgebra.zero_divOf

/- warning: add_monoid_algebra.div_of_zero -> AddMonoidAlgebra.divOf_zero is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x (OfNat.ofNat.{u2} G 0 (OfNat.mk.{u2} G 0 (Zero.zero.{u2} G (AddZeroClass.toHasZero.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))) x
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x (OfNat.ofNat.{u1} G 0 (Zero.toOfNat0.{u1} G (AddRightCancelMonoid.toZero.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) x
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.div_of_zero AddMonoidAlgebra.divOf_zeroₓ'. -/
@[simp]
theorem divOf_zero (x : AddMonoidAlgebra k G) : x /ᵒᶠ 0 = x :=
  by
  ext
  simp only [AddMonoidAlgebra.divOf_apply, zero_add]
#align add_monoid_algebra.div_of_zero AddMonoidAlgebra.divOf_zero

/- warning: add_monoid_algebra.add_div_of -> AddMonoidAlgebra.add_divOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (y : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (HAdd.hAdd.{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) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Distrib.toHasAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))) x y) g) (HAdd.hAdd.{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) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Distrib.toHasAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x g) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 y g))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (y : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Distrib.toAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))) x y) g) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Distrib.toAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x g) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 y g))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.add_div_of AddMonoidAlgebra.add_divOfₓ'. -/
theorem add_divOf (x y : AddMonoidAlgebra k G) (g : G) : (x + y) /ᵒᶠ g = x /ᵒᶠ g + y /ᵒᶠ g :=
  map_add _ _ _
#align add_monoid_algebra.add_div_of AddMonoidAlgebra.add_divOf

/- warning: add_monoid_algebra.div_of_add -> AddMonoidAlgebra.divOf_add is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (a : G) (b : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) a b)) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x a) b)
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (a : G) (b : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) a b)) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x a) b)
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.div_of_add AddMonoidAlgebra.divOf_addₓ'. -/
theorem divOf_add (x : AddMonoidAlgebra k G) (a b : G) : x /ᵒᶠ (a + b) = x /ᵒᶠ a /ᵒᶠ b :=
  by
  ext
  simp only [AddMonoidAlgebra.divOf_apply, add_assoc]
#align add_monoid_algebra.div_of_add AddMonoidAlgebra.divOf_add

/- warning: add_monoid_algebra.div_of_hom -> AddMonoidAlgebra.divOfHom is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G], MonoidHom.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (Multiplicative.mulOneClass.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))) (MulZeroOneClass.toMulOneClass.{max u2 u1} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (NonAssocSemiring.toMulZeroOneClass.{max u2 u1} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (Semiring.toNonAssocSemiring.{max u2 u1} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (AddMonoid.End.semiring.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1)))))
but is expected to have type
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G], MonoidHom.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (Multiplicative.mulOneClass.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))) (MulZeroOneClass.toMulOneClass.{max u1 u2} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (Semiring.toNonAssocSemiring.{max u1 u2} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (AddMonoid.End.semiring.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1)))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.div_of_hom AddMonoidAlgebra.divOfHomₓ'. -/
/-- A bundled version of `add_monoid_algebra.div_of`. -/
@[simps]
noncomputable def divOfHom : Multiplicative G →* AddMonoid.End (AddMonoidAlgebra k G)
    where
  toFun g :=
    { toFun := fun x => divOf x g.toAdd
      map_zero' := zero_divOf _
      map_add' := fun x y => add_divOf x y g.toAdd }
  map_one' := AddMonoidHom.ext divOf_zero
  map_mul' g₁ g₂ :=
    AddMonoidHom.ext fun x => (congr_arg _ (add_comm g₁.toAdd g₂.toAdd)).trans (divOf_add _ _ _)
#align add_monoid_algebra.div_of_hom AddMonoidAlgebra.divOfHom

/- warning: add_monoid_algebra.of'_mul_div_of -> AddMonoidAlgebra.of'_mul_divOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (a : G) (x : AddMonoidAlgebra.{u1, u2} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (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 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 a) x) a) x
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (a : G) (x : AddMonoidAlgebra.{u2, u1} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 a) x) a) x
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.of'_mul_div_of AddMonoidAlgebra.of'_mul_divOfₓ'. -/
theorem of'_mul_divOf (a : G) (x : AddMonoidAlgebra k G) : of' k G a * x /ᵒᶠ a = x :=
  by
  ext b
  rw [AddMonoidAlgebra.divOf_apply, of'_apply, single_mul_apply_aux, one_mul]
  intro c
  exact add_right_inj _
#align add_monoid_algebra.of'_mul_div_of AddMonoidAlgebra.of'_mul_divOf

/- warning: add_monoid_algebra.mul_of'_div_of -> AddMonoidAlgebra.mul_of'_divOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (a : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (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 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) x (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 a)) a) x
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (a : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) x (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 a)) a) x
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.mul_of'_div_of AddMonoidAlgebra.mul_of'_divOfₓ'. -/
theorem mul_of'_divOf (x : AddMonoidAlgebra k G) (a : G) : x * of' k G a /ᵒᶠ a = x :=
  by
  ext b
  rw [AddMonoidAlgebra.divOf_apply, of'_apply, mul_single_apply_aux, mul_one]
  intro c
  rw [add_comm]
  exact add_right_inj _
#align add_monoid_algebra.mul_of'_div_of AddMonoidAlgebra.mul_of'_divOf

/- warning: add_monoid_algebra.of'_div_of -> AddMonoidAlgebra.of'_divOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (a : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 a) a) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 1 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 1 (One.one.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.one.{u1, u2} k G _inst_1 (AddZeroClass.toHasZero.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (a : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 a) a) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 1 (One.toOfNat1.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.one.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toZero.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.of'_div_of AddMonoidAlgebra.of'_divOfₓ'. -/
theorem of'_divOf (a : G) : of' k G a /ᵒᶠ a = 1 := by
  simpa only [one_mul] using mul_of'_div_of (1 : AddMonoidAlgebra k G) a
#align add_monoid_algebra.of'_div_of AddMonoidAlgebra.of'_divOf

#print AddMonoidAlgebra.modOf /-
/-- The remainder upon division by `of' k G g`. -/
noncomputable def modOf (x : AddMonoidAlgebra k G) (g : G) : AddMonoidAlgebra k G :=
  x.filterₓ fun g₁ => ¬∃ g₂, g₁ = g + g₂
#align add_monoid_algebra.mod_of AddMonoidAlgebra.modOf
-/

-- mathport name: «expr %ᵒᶠ »
local infixl:70 " %ᵒᶠ " => modOf

/- warning: add_monoid_algebra.mod_of_apply_of_not_exists_add -> AddMonoidAlgebra.modOf_apply_of_not_exists_add is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G) (g' : G), (Not (Exists.{succ u2} G (fun (d : G) => Eq.{succ u2} G g' (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g d)))) -> (Eq.{succ u1} k (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) g') (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) x g'))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G) (g' : G), (Not (Exists.{succ u1} G (fun (d : G) => Eq.{succ u1} G g' (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)))) -> (Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) g') (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) x g'))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.mod_of_apply_of_not_exists_add AddMonoidAlgebra.modOf_apply_of_not_exists_addₓ'. -/
@[simp]
theorem modOf_apply_of_not_exists_add (x : AddMonoidAlgebra k G) (g : G) (g' : G)
    (h : ¬∃ d, g' = g + d) : (x %ᵒᶠ g) g' = x g' :=
  Finsupp.filter_apply_pos _ _ h
#align add_monoid_algebra.mod_of_apply_of_not_exists_add AddMonoidAlgebra.modOf_apply_of_not_exists_add

/- warning: add_monoid_algebra.mod_of_apply_of_exists_add -> AddMonoidAlgebra.modOf_apply_of_exists_add is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G) (g' : G), (Exists.{succ u2} G (fun (d : G) => Eq.{succ u2} G g' (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g d))) -> (Eq.{succ u1} k (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) g') (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))))))))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G) (g' : G), (Exists.{succ u1} G (fun (d : G) => Eq.{succ u1} G g' (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d))) -> (Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) g') (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') (MonoidWithZero.toZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') (Semiring.toMonoidWithZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') _inst_1)))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.mod_of_apply_of_exists_add AddMonoidAlgebra.modOf_apply_of_exists_addₓ'. -/
@[simp]
theorem modOf_apply_of_exists_add (x : AddMonoidAlgebra k G) (g : G) (g' : G)
    (h : ∃ d, g' = g + d) : (x %ᵒᶠ g) g' = 0 :=
  Finsupp.filter_apply_neg _ _ <| by rwa [Classical.not_not]
#align add_monoid_algebra.mod_of_apply_of_exists_add AddMonoidAlgebra.modOf_apply_of_exists_add

/- warning: add_monoid_algebra.mod_of_apply_add_self -> AddMonoidAlgebra.modOf_apply_add_self is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G) (d : G), Eq.{succ u1} k (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) d g)) (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)))))))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G) (d : G), Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) (MonoidWithZero.toZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) (Semiring.toMonoidWithZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) _inst_1))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.mod_of_apply_add_self AddMonoidAlgebra.modOf_apply_add_selfₓ'. -/
@[simp]
theorem modOf_apply_add_self (x : AddMonoidAlgebra k G) (g : G) (d : G) : (x %ᵒᶠ g) (d + g) = 0 :=
  modOf_apply_of_exists_add _ _ _ ⟨_, add_comm _ _⟩
#align add_monoid_algebra.mod_of_apply_add_self AddMonoidAlgebra.modOf_apply_add_self

/- warning: add_monoid_algebra.mod_of_apply_self_add -> AddMonoidAlgebra.modOf_apply_self_add is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G) (d : G), Eq.{succ u1} k (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g d)) (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)))))))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G) (d : G), Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) (MonoidWithZero.toZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) (Semiring.toMonoidWithZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) _inst_1))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.mod_of_apply_self_add AddMonoidAlgebra.modOf_apply_self_addₓ'. -/
@[simp]
theorem modOf_apply_self_add (x : AddMonoidAlgebra k G) (g : G) (d : G) : (x %ᵒᶠ g) (g + d) = 0 :=
  modOf_apply_of_exists_add _ _ _ ⟨_, rfl⟩
#align add_monoid_algebra.mod_of_apply_self_add AddMonoidAlgebra.modOf_apply_self_add

/- warning: add_monoid_algebra.of'_mul_mod_of -> AddMonoidAlgebra.of'_mul_modOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (g : G) (x : AddMonoidAlgebra.{u1, u2} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 (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 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g) x) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (g : G) (x : AddMonoidAlgebra.{u2, u1} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g) x) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.of'_mul_mod_of AddMonoidAlgebra.of'_mul_modOfₓ'. -/
theorem of'_mul_modOf (g : G) (x : AddMonoidAlgebra k G) : of' k G g * x %ᵒᶠ g = 0 :=
  by
  ext g'
  rw [Finsupp.zero_apply]
  obtain ⟨d, rfl⟩ | h := em (∃ d, g' = g + d)
  · rw [mod_of_apply_self_add]
  · rw [mod_of_apply_of_not_exists_add _ _ _ h, of'_apply, single_mul_apply_of_not_exists_add _ _ h]
#align add_monoid_algebra.of'_mul_mod_of AddMonoidAlgebra.of'_mul_modOf

/- warning: add_monoid_algebra.mul_of'_mod_of -> AddMonoidAlgebra.mul_of'_modOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 (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 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) x (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g)) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) x (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g)) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.mul_of'_mod_of AddMonoidAlgebra.mul_of'_modOfₓ'. -/
theorem mul_of'_modOf (x : AddMonoidAlgebra k G) (g : G) : x * of' k G g %ᵒᶠ g = 0 :=
  by
  ext g'
  rw [Finsupp.zero_apply]
  obtain ⟨d, rfl⟩ | h := em (∃ d, g' = g + d)
  · rw [mod_of_apply_self_add]
  · rw [mod_of_apply_of_not_exists_add _ _ _ h, of'_apply, mul_single_apply_of_not_exists_add]
    simpa only [add_comm] using h
#align add_monoid_algebra.mul_of'_mod_of AddMonoidAlgebra.mul_of'_modOf

/- warning: add_monoid_algebra.of'_mod_of -> AddMonoidAlgebra.of'_modOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.of'_mod_of AddMonoidAlgebra.of'_modOfₓ'. -/
theorem of'_modOf (g : G) : of' k G g %ᵒᶠ g = 0 := by
  simpa only [one_mul] using mul_of'_mod_of (1 : AddMonoidAlgebra k G) g
#align add_monoid_algebra.of'_mod_of AddMonoidAlgebra.of'_modOf

/- warning: add_monoid_algebra.div_of_add_mod_of -> AddMonoidAlgebra.divOf_add_modOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G), Eq.{succ (max u2 u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (HAdd.hAdd.{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) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Distrib.toHasAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))) (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 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x g)) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g)) x
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Distrib.toAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x g)) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g)) x
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.div_of_add_mod_of AddMonoidAlgebra.divOf_add_modOfₓ'. -/
theorem divOf_add_modOf (x : AddMonoidAlgebra k G) (g : G) : of' k G g * (x /ᵒᶠ g) + x %ᵒᶠ g = x :=
  by
  ext g'
  simp_rw [Finsupp.add_apply]
  obtain ⟨d, rfl⟩ | h := em (∃ d, g' = g + d)
  swap
  ·
    rw [mod_of_apply_of_not_exists_add _ _ _ h, of'_apply, single_mul_apply_of_not_exists_add _ _ h,
      zero_add]
  · rw [mod_of_apply_self_add, add_zero]
    rw [of'_apply, single_mul_apply_aux _ _ _, one_mul, div_of_apply]
    intro a
    exact add_right_inj _
#align add_monoid_algebra.div_of_add_mod_of AddMonoidAlgebra.divOf_add_modOf

/- warning: add_monoid_algebra.mod_of_add_div_of -> AddMonoidAlgebra.modOf_add_divOf is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G), Eq.{succ (max u2 u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (HAdd.hAdd.{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) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Distrib.toHasAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) (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 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x g))) x
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Distrib.toAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x g))) x
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.mod_of_add_div_of AddMonoidAlgebra.modOf_add_divOfₓ'. -/
theorem modOf_add_divOf (x : AddMonoidAlgebra k G) (g : G) : x %ᵒᶠ g + of' k G g * (x /ᵒᶠ g) = x :=
  by rw [add_comm, div_of_add_mod_of]
#align add_monoid_algebra.mod_of_add_div_of AddMonoidAlgebra.modOf_add_divOf

/- warning: add_monoid_algebra.of'_dvd_iff_mod_of_eq_zero -> AddMonoidAlgebra.of'_dvd_iff_modOf_eq_zero is a dubious translation:
lean 3 declaration is
  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] {x : AddMonoidAlgebra.{u1, u2} k G _inst_1} {g : G}, Iff (Dvd.Dvd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (semigroupDvd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (SemigroupWithZero.toSemigroup.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalSemiring.toSemigroupWithZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddSemigroup.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g) x) (Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))))))
but is expected to have type
  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] {x : AddMonoidAlgebra.{u2, u1} k G _inst_1} {g : G}, Iff (Dvd.dvd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (semigroupDvd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (SemigroupWithZero.toSemigroup.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (NonUnitalSemiring.toSemigroupWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.nonUnitalSemiring.{u2, u1} k G _inst_1 (AddMonoid.toAddSemigroup.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))))) (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g) x) (Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))))))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.of'_dvd_iff_mod_of_eq_zero AddMonoidAlgebra.of'_dvd_iff_modOf_eq_zeroₓ'. -/
theorem of'_dvd_iff_modOf_eq_zero {x : AddMonoidAlgebra k G} {g : G} :
    of' k G g ∣ x ↔ x %ᵒᶠ g = 0 := by
  constructor
  · rintro ⟨x, rfl⟩
    rw [of'_mul_mod_of]
  · intro h
    rw [← div_of_add_mod_of x g, h, add_zero]
    exact dvd_mul_right _ _
#align add_monoid_algebra.of'_dvd_iff_mod_of_eq_zero AddMonoidAlgebra.of'_dvd_iff_modOf_eq_zero

end

end AddMonoidAlgebra