-- Module: Mathlib.RingTheory.FinitePresentation
Goal:
R : Type w₁
A : Type w₂
B : Type w₃
inst : CommRing R
inst_1 : CommRing A
inst_2 : Algebra R A
inst_3 : CommRing B
inst_4 : Algebra R B
inst_5 : Algebra A B
inst_6 : IsScalarTower R A B
inst_7 : FinitePresentation R B
inst_8 : FiniteType R A
n : ℕ
f : MvPolynomial (Fin n) R →ₐ[R] B
hf : Surjective.{w₁ + 1, w₃ + 1} (α := MvPolynomial (Fin n) R) (β := B) (⇑f : (a : MvPolynomial (Fin n) R) → B)
s : Finset (MvPolynomial (Fin n) R)
hs : Eq (α := Ideal (MvPolynomial (Fin n) R)) (Ideal.span (↑s : Set (MvPolynomial (Fin n) R))) (RingHom.ker f.toRingHom)
RX : Type w₁ := MvPolynomial (Fin n) R
AX : Type w₂ := MvPolynomial (Fin n) A
t : Finset A
ht : Eq (α := Subalgebra R A) (adjoin R (↑t : Set A)) ⊤
t' : (i : ↥t) → MvPolynomial (Fin n) R
ht' :
  ∀ (i : ↥t),
    Eq.{w₃ + 1} (α := B) ((f : (a : MvPolynomial (Fin n) R) → B) (t' i) : B)
      ((algebraMap A B : (a : A) → B) (↑i : A) : B)
ht'' :
  Eq (α := Subalgebra R AX) (adjoin R ((⇑(algebraMap A AX) : (a : A) → AX) '' (↑t : Set A) ∪ Set.range MvPolynomial.X))
    ⊤
g : ↥t → AX :=
  fun (x : ↥t) ↦
    HSub.hSub (α := MvPolynomial (Fin n) A) (β := MvPolynomial (Fin n) A)
      ((MvPolynomial.C : (a : A) → MvPolynomial (Fin n) A) (↑x : A) : MvPolynomial (Fin n) A)
      (((MvPolynomial.map (algebraMap R A) : RingHom.{w₁, w₂} (MvPolynomial (Fin n) R) (MvPolynomial (Fin n) A)) :
            (a : MvPolynomial (Fin n) R) → MvPolynomial (Fin n) A)
          (t' x) :
        MvPolynomial (Fin n) A)
s₀_1 : Set (MvPolynomial (Fin n) A) :=
  (⇑(MvPolynomial.map (algebraMap R A)) : (a : MvPolynomial (Fin n) R) → MvPolynomial (Fin n) A) ''
      (↑s : Set (MvPolynomial (Fin n) R)) ∪
    Set.range g
I : Ideal (MvPolynomial (Fin n) A) :=
  RingHom.ker (F := MvPolynomial (Fin n) A →ₐ[A] B)
    (MvPolynomial.aeval
      (Function.comp.{1, w₁ + 1, w₃ + 1} (β := MvPolynomial (Fin n) R) (⇑f : (a : MvPolynomial (Fin n) R) → B)
        MvPolynomial.X))
leI :
  LE.le (α := Ideal (MvPolynomial (Fin n) A))
    (Ideal.span
      ((⇑(MvPolynomial.map (algebraMap R A)) : (a : MvPolynomial (Fin n) R) → MvPolynomial (Fin n) A) ''
          (↑s : Set (MvPolynomial (Fin n) R)) ∪
        Set.range g))
    (RingHom.ker (F := MvPolynomial (Fin n) A →ₐ[A] B)
      (MvPolynomial.aeval
        (Function.comp.{1, w₁ + 1, w₃ + 1} (β := MvPolynomial (Fin n) R) (⇑f : (a : MvPolynomial (Fin n) R) → B)
          MvPolynomial.X)))
x : MvPolynomial (Fin n) A
hx :
  Eq.{w₃ + 1} (α := B)
    ((MvPolynomial.aeval
            (Function.comp.{1, w₁ + 1, w₃ + 1} (β := MvPolynomial (Fin n) R) (⇑f : (a : MvPolynomial (Fin n) R) → B)
              MvPolynomial.X) :
          (a : MvPolynomial (Fin n) A) → B)
        x :
      B)
    (0 : B)
s₀ : Set (MvPolynomial (Fin n) A) :=
  (⇑(MvPolynomial.map (algebraMap R A)) : (a : MvPolynomial (Fin n) R) → MvPolynomial (Fin n) A) ''
      (↑s : Set (MvPolynomial (Fin n) R)) ∪
    Set.range g
⊢ x ∈
    Subsemiring.toAddSubmonoid
        (Subring.toSubsemiring
          (RingHom.range.{w₁, w₂} (R := MvPolynomial (Fin n) R) (MvPolynomial.map (algebraMap R A)))) ⊔
      Submodule.toAddSubmonoid (Ideal.span s₀)

Tactic:
have : x ∈ (MvPolynomial.map (algebraMap R A) : _ →+* AX).range.toAddSubmonoid ⊔
      (Ideal.span s₀).toAddSubmonoid := by
      have : x ∈ (⊤ : Subalgebra R AX) := trivial
      rw [← ht''] at this
      refine adjoin_induction ?_ ?_ ?_ ?_ this
      · rintro _ (⟨x, hx, rfl⟩ | ⟨i, rfl⟩)
        · rw [MvPolynomial.algebraMap_eq, ← sub_add_cancel (MvPolynomial.C x)
            (map (algebraMap R A) (t' ⟨x, hx⟩)), add_comm]
          apply AddSubmonoid.add_mem_sup
          · exact Set.mem_range_self _
          · apply Ideal.subset_span
            apply Set.mem_union_right
            exact Set.mem_range_self _
        · apply AddSubmonoid.mem_sup_left
          exact ⟨X i, map_X _ _⟩
      · intro r
        apply AddSubmonoid.mem_sup_left
        exact ⟨C r, map_C _ _⟩
      · intro _ _ _ _ h₁ h₂
        exact add_mem h₁ h₂
      · intro x₁ x₂ _ _ h₁ h₂
        obtain ⟨_, ⟨p₁, rfl⟩, q₁, hq₁, rfl⟩ := AddSubmonoid.mem_sup.mp h₁
        obtain ⟨_, ⟨p₂, rfl⟩, q₂, hq₂, rfl⟩ := AddSubmonoid.mem_sup.mp h₂
        rw [add_mul, mul_add, add_assoc, ← map_mul]
        apply AddSubmonoid.add_mem_sup
        · exact Set.mem_range_self _
        · refine add_mem (Ideal.mul_mem_left _ _ hq₂) (Ideal.mul_mem_right _ _ hq₁)