l3lab/ntp-mathlib huggingface dataset:
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.

We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
    {x : MonoidAlgebra k G} :
    x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
  let RHS : Ideal (MonoidAlgebra k G) :=
    { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
      add_mem' := fun {x y} hx hy m hm => by
        classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
      zero_mem' := fun m hm => by cases hm
      smul_mem' := fun x y hy m hm => by
        classical
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨xm, -, hm⟩ := hm
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        

Proof state:
case intro.intro
k : Type u_1
A : Type u_2
G : Type u_3
inst✝¹ : Monoid G
inst✝ : Semiring k
s : Set G
x✝ x y : MonoidAlgebra k G
hy :
  y ∈
    {
          toAddSubsemigroup :=
            { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
              add_mem' :=
                (_ :
                  ∀ {x y : MonoidAlgebra k G},
                    x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                      y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                        ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
          zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') }.toAddSubsemigroup.carrier
m xm : G
hm : ∃ a ∈ y.support, m ∈ (single (xm * a) (x xm * y a)).support
⊢ ∃ m' ∈ s, ∃ d, m = d * m'

Next tactic:
obtain ⟨ym, hym, hm⟩ := hm
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.

We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
    {x : MonoidAlgebra k G} :
    x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
  let RHS : Ideal (MonoidAlgebra k G) :=
    { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
      add_mem' := fun {x y} hx hy m hm => by
        classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
      zero_mem' := fun m hm => by cases hm
      smul_mem' := fun x y hy m hm => by
        classical
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨xm, -, hm⟩ := hm
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨ym, hym, hm⟩ := hm
        

Proof state:
case intro.intro.intro.intro
k : Type u_1
A : Type u_2
G : Type u_3
inst✝¹ : Monoid G
inst✝ : Semiring k
s : Set G
x✝ x y : MonoidAlgebra k G
hy :
  y ∈
    {
          toAddSubsemigroup :=
            { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
              add_mem' :=
                (_ :
                  ∀ {x y : MonoidAlgebra k G},
                    x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                      y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                        ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
          zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') }.toAddSubsemigroup.carrier
m xm ym : G
hym : ym ∈ y.support
hm : m ∈ (single (xm * ym) (x xm * y ym)).support
⊢ ∃ m' ∈ s, ∃ d, m = d * m'

Next tactic:
replace hm := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.

We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
    {x : MonoidAlgebra k G} :
    x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
  let RHS : Ideal (MonoidAlgebra k G) :=
    { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
      add_mem' := fun {x y} hx hy m hm => by
        classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
      zero_mem' := fun m hm => by cases hm
      smul_mem' := fun x y hy m hm => by
        classical
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨xm, -, hm⟩ := hm
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨ym, hym, hm⟩ := hm
        replace hm := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
        

Proof state:
case intro.intro.intro.intro
k : Type u_1
A : Type u_2
G : Type u_3
inst✝¹ : Monoid G
inst✝ : Semiring k
s : Set G
x✝ x y : MonoidAlgebra k G
hy :
  y ∈
    {
          toAddSubsemigroup :=
            { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
              add_mem' :=
                (_ :
                  ∀ {x y : MonoidAlgebra k G},
                    x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                      y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                        ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
          zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') }.toAddSubsemigroup.carrier
m xm ym : G
hym : ym ∈ y.support
hm : m = xm * ym
⊢ ∃ m' ∈ s, ∃ d, m = d * m'

Next tactic:
obtain rfl := hm
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.

We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
    {x : MonoidAlgebra k G} :
    x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
  let RHS : Ideal (MonoidAlgebra k G) :=
    { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
      add_mem' := fun {x y} hx hy m hm => by
        classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
      zero_mem' := fun m hm => by cases hm
      smul_mem' := fun x y hy m hm => by
        classical
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨xm, -, hm⟩ := hm
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨ym, hym, hm⟩ := hm
        replace hm := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
        obtain rfl := hm
        -- porting note: changed `Exists.imp` to `And.imp_right` due to change in `∃ x ∈ s`
        -- elaboration
        

Proof state:
case intro.intro.intro.intro
k : Type u_1
A : Type u_2
G : Type u_3
inst✝¹ : Monoid G
inst✝ : Semiring k
s : Set G
x✝ x y : MonoidAlgebra k G
hy :
  y ∈
    {
          toAddSubsemigroup :=
            { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
              add_mem' :=
                (_ :
                  ∀ {x y : MonoidAlgebra k G},
                    x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                      y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                        ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
          zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') }.toAddSubsemigroup.carrier
xm ym : G
hym : ym ∈ y.support
⊢ ∃ m' ∈ s, ∃ d, xm * ym = d * m'

Next tactic:
refine' (hy _ hym).imp fun sm p => And.imp_right _ p
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.

We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
    {x : MonoidAlgebra k G} :
    x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
  let RHS : Ideal (MonoidAlgebra k G) :=
    { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
      add_mem' := fun {x y} hx hy m hm => by
        classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
      zero_mem' := fun m hm => by cases hm
      smul_mem' := fun x y hy m hm => by
        classical
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨xm, -, hm⟩ := hm
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨ym, hym, hm⟩ := hm
        replace hm := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
        obtain rfl := hm
        -- porting note: changed `Exists.imp` to `And.imp_right` due to change in `∃ x ∈ s`
        -- elaboration
        refine' (hy _ hym).imp fun sm p => And.imp_right _ p
        

Proof state:
case intro.intro.intro.intro
k : Type u_1
A : Type u_2
G : Type u_3
inst✝¹ : Monoid G
inst✝ : Semiring k
s : Set G
x✝ x y : MonoidAlgebra k G
hy :
  y ∈
    {
          toAddSubsemigroup :=
            { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
              add_mem' :=
                (_ :
                  ∀ {x y : MonoidAlgebra k G},
                    x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                      y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                        ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
          zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') }.toAddSubsemigroup.carrier
xm ym : G
hym : ym ∈ y.support
sm : G
p : sm ∈ s ∧ ∃ d, ym = d * sm
⊢ (∃ d, ym = d * sm) → ∃ d, xm * ym = d * sm

Next tactic:
rintro ⟨d, rfl⟩
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.

We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
    {x : MonoidAlgebra k G} :
    x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
  let RHS : Ideal (MonoidAlgebra k G) :=
    { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
      add_mem' := fun {x y} hx hy m hm => by
        classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
      zero_mem' := fun m hm => by cases hm
      smul_mem' := fun x y hy m hm => by
        classical
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨xm, -, hm⟩ := hm
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨ym, hym, hm⟩ := hm
        replace hm := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
        obtain rfl := hm
        -- porting note: changed `Exists.imp` to `And.imp_right` due to change in `∃ x ∈ s`
        -- elaboration
        refine' (hy _ hym).imp fun sm p => And.imp_right _ p
        rintro ⟨d, rfl⟩
        

Proof state:
case intro.intro.intro.intro.intro
k : Type u_1
A : Type u_2
G : Type u_3
inst✝¹ : Monoid G
inst✝ : Semiring k
s : Set G
x✝ x y : MonoidAlgebra k G
hy :
  y ∈
    {
          toAddSubsemigroup :=
            { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
              add_mem' :=
                (_ :
                  ∀ {x y : MonoidAlgebra k G},
                    x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                      y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                        ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
          zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') }.toAddSubsemigroup.carrier
xm sm d : G
hym : d * sm ∈ y.support
p : sm ∈ s ∧ ∃ d_1, d * sm = d_1 * sm
⊢ ∃ d_1, xm * (d * sm) = d_1 * sm

Next tactic:
exact ⟨xm * d, (mul_assoc _ _ _).symm⟩
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.

We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
    {x : MonoidAlgebra k G} :
    x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
  let RHS : Ideal (MonoidAlgebra k G) :=
    { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
      add_mem' := fun {x y} hx hy m hm => by
        classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
      zero_mem' := fun m hm => by cases hm
      smul_mem' := fun x y hy m hm => by
        classical
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨xm, -, hm⟩ := hm
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨ym, hym, hm⟩ := hm
        replace hm := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
        obtain rfl := hm
        -- porting note: changed `Exists.imp` to `And.imp_right` due to change in `∃ x ∈ s`
        -- elaboration
        refine' (hy _ hym).imp fun sm p => And.imp_right _ p
        rintro ⟨d, rfl⟩
        exact ⟨xm * d, (mul_assoc _ _ _).symm⟩ }
  

Proof state:
k : Type u_1
A : Type u_2
G : Type u_3
inst✝¹ : Monoid G
inst✝ : Semiring k
s : Set G
x : MonoidAlgebra k G
RHS : Ideal (MonoidAlgebra k G) :=
  {
    toAddSubmonoid :=
      {
        toAddSubsemigroup :=
          { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
            add_mem' :=
              (_ :
                ∀ {x y : MonoidAlgebra k G},
                  x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                    y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                      ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
        zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') },
    smul_mem' :=
      (_ :
        ∀ (x y : MonoidAlgebra k G),
          y ∈
              {
                    toAddSubsemigroup :=
                      { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
                        add_mem' :=
                          (_ :
                            ∀ {x y : MonoidAlgebra k G},
                              x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                                y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                                  ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
                    zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') }.toAddSubsemigroup.carrier →
            ∀ m ∈ (x • y).support, ∃ m' ∈ s, ∃ d, m = d * m') }
⊢ x ∈ Ideal.span (⇑(of k G) '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m'

Next tactic:
change _ ↔ x ∈ RHS
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.

We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
    {x : MonoidAlgebra k G} :
    x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
  let RHS : Ideal (MonoidAlgebra k G) :=
    { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
      add_mem' := fun {x y} hx hy m hm => by
        classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
      zero_mem' := fun m hm => by cases hm
      smul_mem' := fun x y hy m hm => by
        classical
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨xm, -, hm⟩ := hm
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨ym, hym, hm⟩ := hm
        replace hm := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
        obtain rfl := hm
        -- porting note: changed `Exists.imp` to `And.imp_right` due to change in `∃ x ∈ s`
        -- elaboration
        refine' (hy _ hym).imp fun sm p => And.imp_right _ p
        rintro ⟨d, rfl⟩
        exact ⟨xm * d, (mul_assoc _ _ _).symm⟩ }
  change _ ↔ x ∈ RHS
  

Proof state:
k : Type u_1
A : Type u_2
G : Type u_3
inst✝¹ : Monoid G
inst✝ : Semiring k
s : Set G
x : MonoidAlgebra k G
RHS : Ideal (MonoidAlgebra k G) :=
  {
    toAddSubmonoid :=
      {
        toAddSubsemigroup :=
          { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
            add_mem' :=
              (_ :
                ∀ {x y : MonoidAlgebra k G},
                  x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                    y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                      ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
        zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') },
    smul_mem' :=
      (_ :
        ∀ (x y : MonoidAlgebra k G),
          y ∈
              {
                    toAddSubsemigroup :=
                      { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
                        add_mem' :=
                          (_ :
                            ∀ {x y : MonoidAlgebra k G},
                              x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                                y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                                  ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
                    zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') }.toAddSubsemigroup.carrier →
            ∀ m ∈ (x • y).support, ∃ m' ∈ s, ∃ d, m = d * m') }
⊢ x ∈ Ideal.span (⇑(of k G) '' s) ↔ x ∈ RHS

Next tactic:
constructor
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.

We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
    {x : MonoidAlgebra k G} :
    x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
  let RHS : Ideal (MonoidAlgebra k G) :=
    { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
      add_mem' := fun {x y} hx hy m hm => by
        classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
      zero_mem' := fun m hm => by cases hm
      smul_mem' := fun x y hy m hm => by
        classical
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨xm, -, hm⟩ := hm
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨ym, hym, hm⟩ := hm
        replace hm := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
        obtain rfl := hm
        -- porting note: changed `Exists.imp` to `And.imp_right` due to change in `∃ x ∈ s`
        -- elaboration
        refine' (hy _ hym).imp fun sm p => And.imp_right _ p
        rintro ⟨d, rfl⟩
        exact ⟨xm * d, (mul_assoc _ _ _).symm⟩ }
  change _ ↔ x ∈ RHS
  constructor
  · 

Proof state:
case mp
k : Type u_1
A : Type u_2
G : Type u_3
inst✝¹ : Monoid G
inst✝ : Semiring k
s : Set G
x : MonoidAlgebra k G
RHS : Ideal (MonoidAlgebra k G) :=
  {
    toAddSubmonoid :=
      {
        toAddSubsemigroup :=
          { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
            add_mem' :=
              (_ :
                ∀ {x y : MonoidAlgebra k G},
                  x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                    y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                      ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
        zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') },
    smul_mem' :=
      (_ :
        ∀ (x y : MonoidAlgebra k G),
          y ∈
              {
                    toAddSubsemigroup :=
                      { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
                        add_mem' :=
                          (_ :
                            ∀ {x y : MonoidAlgebra k G},
                              x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                                y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                                  ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
                    zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') }.toAddSubsemigroup.carrier →
            ∀ m ∈ (x • y).support, ∃ m' ∈ s, ∃ d, m = d * m') }
⊢ x ∈ Ideal.span (⇑(of k G) '' s) → x ∈ RHS

Next tactic:
revert x
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.

We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
    {x : MonoidAlgebra k G} :
    x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
  let RHS : Ideal (MonoidAlgebra k G) :=
    { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
      add_mem' := fun {x y} hx hy m hm => by
        classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
      zero_mem' := fun m hm => by cases hm
      smul_mem' := fun x y hy m hm => by
        classical
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨xm, -, hm⟩ := hm
        replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
        obtain ⟨ym, hym, hm⟩ := hm
        replace hm := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
        obtain rfl := hm
        -- porting note: changed `Exists.imp` to `And.imp_right` due to change in `∃ x ∈ s`
        -- elaboration
        refine' (hy _ hym).imp fun sm p => And.imp_right _ p
        rintro ⟨d, rfl⟩
        exact ⟨xm * d, (mul_assoc _ _ _).symm⟩ }
  change _ ↔ x ∈ RHS
  constructor
  · revert x
    

Proof state:
case mp
k : Type u_1
A : Type u_2
G : Type u_3
inst✝¹ : Monoid G
inst✝ : Semiring k
s : Set G
RHS : Ideal (MonoidAlgebra k G) :=
  {
    toAddSubmonoid :=
      {
        toAddSubsemigroup :=
          { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
            add_mem' :=
              (_ :
                ∀ {x y : MonoidAlgebra k G},
                  x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                    y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                      ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
        zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') },
    smul_mem' :=
      (_ :
        ∀ (x y : MonoidAlgebra k G),
          y ∈
              {
                    toAddSubsemigroup :=
                      { carrier := {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'},
                        add_mem' :=
                          (_ :
                            ∀ {x y : MonoidAlgebra k G},
                              x ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                                y ∈ {p | ∀ m ∈ p.support, ∃ m' ∈ s, ∃ d, m = d * m'} →
                                  ∀ m ∈ (x + y).support, ∃ m' ∈ s, ∃ d, m = d * m') },
                    zero_mem' := (_ : ∀ m ∈ 0.support, ∃ m' ∈ s, ∃ d, m = d * m') }.toAddSubsemigroup.carrier →
            ∀ m ∈ (x • y).support, ∃ m' ∈ s, ∃ d, m = d * m') }
⊢ ∀ {x : MonoidAlgebra k G}, x ∈ Ideal.span (⇑(of k G) '' s) → x ∈ RHS

Next tactic:
rw [← SetLike.le_def]