-- Module: Mathlib.RingTheory.Spectrum.Prime.ChevalleyComplexity
Goal:
R₀ : Type u_1
inst : CommRing R₀
n : ℕ
R : Type u_6
inst_1 : CommRing R
inst_2 : Algebra R₀ R
c : R
i : Fin n
e : InductionObj R n
hi : c = (e.val i).leadingCoeff
hc : c ≠ 0
q₁ : R →ₐ[R₀] Localization.Away c := IsScalarTower.toAlgHom R₀ R (Localization.Away c)
q₂ : R →ₐ[R₀] HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}) := Ideal.Quotient.mkₐ R₀ (Ideal.span {c})
q₂_surjective :
  Surjective (α := R) (β := HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c})) (⇑q₂ : (a : R) → R ⧸ Ideal.span {c})
e₁ : InductionObj (Localization.Away c) n :=
  {
    val :=
      HSMul.hSMul (α := (Localization.Away c)[X]) (β := Fin n → (Localization.Away c)[X])
        ((Polynomial.C : (a : Localization.Away c) → (Localization.Away c)[X]) (IsLocalization.Away.invSelf c))
        ((⇑(mapRingHom (↑q₁ : R →+* Localization.Away c)) : (a : R[X]) → (Localization.Away c)[X]) ∘ e.val) }
e₂ : InductionObj (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c})) n :=
  { val := (⇑(mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c})) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) ∘ e.val }
degBound_e₁_le : e₁.degBound ≤ e.degBound
degBound_e₂_lt : e₂.degBound < e.degBound
H₁ : Statement R₀ (Localization.Away c) n e₁
H₂ : Statement R₀ (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c})) n e₂
f : R[X]
T₁ : ConstructibleSetData (Localization.Away c)
T₂ : ConstructibleSetData (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))
hT₁ :
  comap Polynomial.C ''
      (zeroLocus (Set.range e₁.val) \
        zeroLocus
          (singleton (α := (Localization.Away c)[X])
            ((mapRingHom (↑q₁ : R →+* Localization.Away c) : (a : R[X]) → (Localization.Away c)[X]) f :
              (Localization.Away c)[X]))) =
    T₁.toSet
hT₁deg : ∀ (x : BasicConstructibleSetData (Localization.Away c)) (x_1 : x ∈ T₁), x.n ≤ e₁.degBound
hT₂ :
  comap Polynomial.C ''
      (zeroLocus (Set.range e₂.val) \
        zeroLocus
          (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
            ((mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c}) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
              (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X]))) =
    T₂.toSet
hT₂deg :
  ∀ (x : BasicConstructibleSetData (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))) (x_1 : x ∈ T₂),
    x.n ≤ e₂.degBound
x : Invertible (α := Localization.Away c) ((q₁ : (a : R) → Localization.Away c) c) :=
  { invOf := IsLocalization.Away.invSelf c, invOf_mul_self := ⋯, mul_invOf_self := ⋯ }
he₁span :
  HPow.hPow (α := Submodule R₀ (Localization.Away c)) (coeffSubmodule R₀ e₁) e₁.powBound =
    @Invertible.invOf _ MulOne.toMul MulOne.toOne
        (HPow.hPow (α := Localization.Away c) ((q₁ : (a : R) → Localization.Away c) c) e₁.powBound) _ •
      Submodule.map q₁.toLinearMap
        (HPow.hPow (α := Submodule R₀ R) (span R₀ ({c} ∪ ⋃ (i : Fin n), coeff(e.val i))) e₁.powBound)
g₁ : (x : BasicConstructibleSetData (Localization.Away c)) → (i : Fin x.n) → R
hg₁ :
  ∀ (x : BasicConstructibleSetData (Localization.Away c)) (hx : x ∈ T₁) (i : Fin x.n),
    g₁ x i ∈ (↑(HPow.hPow (α := Submodule R₀ R) (span R₀ ({c} ∪ ⋃ (i : Fin n), coeff(e.val i))) e₁.powBound) : Set R)
hq₁g₁ :
  ∀ (x : BasicConstructibleSetData (Localization.Away c)) (hx : x ∈ T₁) (i : Fin x.n),
    (q₁.toLinearMap : (a : R) → Localization.Away c) (g₁ x i) =
      HPow.hPow (α := Localization.Away c) ((q₁ : (a : R) → Localization.Away c) c) e₁.powBound * x.g i
n₁ : (z : Localization.Away c) → ℕ
f₁ : (z : Localization.Away c) → R
hf₁ :
  ∀ (x : Localization.Away c),
    x * HPow.hPow (α := Localization.Away c) ((q₁ : (a : R) → Localization.Away c) c) (n₁ x) =
      (q₁ : (a : R) → Localization.Away c) (f₁ x)
g₂ : (x : BasicConstructibleSetData (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))) → (i : Fin x.n) → R
hg₂ :
  ∀ (x : BasicConstructibleSetData (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))) (x_1 : x ∈ T₂)
    (i : Fin x.n), g₂ x i ∈ (↑(HPow.hPow (α := Submodule R₀ R) (coeffSubmodule R₀ e) e₂.powBound) : Set R)
hq₂g₂ :
  ∀ (x : BasicConstructibleSetData (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))) (x_1 : x ∈ T₂)
    (i : Fin x.n), (q₂.toLinearMap : (a : R) → R ⧸ Ideal.span {c}) (g₂ x i) = x.g i
f₂ : (b : HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c})) → R
hf₂ : ∀ (x : HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c})), (q₂ : (a : R) → R ⧸ Ideal.span {c}) (f₂ x) = x
S₁ : Finset (BasicConstructibleSetData R) :=
  Finset.image (fun (x : BasicConstructibleSetData (Localization.Away c)) ↦ { f := c * f₁ x.f, n := x.n, g := g₁ x }) T₁
S₂ : Finset (BasicConstructibleSetData R) :=
  Finset.image
    (fun (x : BasicConstructibleSetData (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))) ↦
      { f := f₂ x.f, n := x.n + 1, g := Fin.cons (α := fun (a : Fin (x.n + 1)) ↦ R) c (g₂ x) })
    T₂
h :
  comap (mapRingHom q₂.toRingHom) ⁻¹' zeroLocus (Set.range e.val) \ comap (mapRingHom q₂.toRingHom) ⁻¹' zeroLocus {f} =
    zeroLocus (Set.range e₂.val) \
      zeroLocus
        (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
          ((mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c}) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
            (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X]))
h₁ :
  zeroLocus ((⇑(mapRingHom q₂.toRingHom) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) '' Set.range e.val) \
      comap (mapRingHom q₂.toRingHom) ⁻¹' zeroLocus {f} =
    zeroLocus (Set.range e₂.val) \
      zeroLocus
        (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
          ((mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c}) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
            (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X]))
h₂ :
  Eq (α := Set (PrimeSpectrum (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X]))
    (zeroLocus ((⇑(mapRingHom q₂.toRingHom) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) '' Set.range e.val) \
      zeroLocus (Set.image (α := R[X]) (⇑(mapRingHom q₂.toRingHom) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) {f}))
    (zeroLocus (Set.range e₂.val) \
      zeroLocus
        (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
          ((mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c}) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
            (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])))
h₃ :
  Eq (α := Set (PrimeSpectrum (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X]))
    (zeroLocus ((⇑(mapRingHom q₂.toRingHom) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) '' Set.range e.val) \
      zeroLocus
        (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
          ((mapRingHom q₂.toRingHom : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
            (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])))
    (zeroLocus (Set.range e₂.val) \
      zeroLocus
        (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
          ((mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c}) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
            (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])))
h₄ :
  Eq (α := Set (PrimeSpectrum (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X]))
    (zeroLocus ((⇑(mapRingHom q₂.toRingHom) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) '' Set.range e.val) \
      zeroLocus
        (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
          ((mapRingHom q₂.toRingHom : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
            (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])))
    (zeroLocus
        ((⇑(mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c})) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) '' Set.range e.val) \
      zeroLocus
        (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
          ((mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c}) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
            (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])))
h₅ h₆ :
  Eq (α := Set (PrimeSpectrum (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X]))
    (zeroLocus
        ((⇑(mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c})) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) '' Set.range e.val) \
      zeroLocus
        (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
          ((mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c}) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
            (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])))
    (zeroLocus
        ((⇑(mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c})) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) '' Set.range e.val) \
      zeroLocus
        (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
          ((mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c}) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
            (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])))
⊢ comap (mapRingHom q₂.toRingHom) ⁻¹' (zeroLocus (Set.range e.val) \ zeroLocus {f}) =
    zeroLocus (Set.range e₂.val) \
      zeroLocus
        (singleton (α := (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X])
          ((mapRingHom (↑q₂ : R →+* R ⧸ Ideal.span {c}) : (a : R[X]) → (R ⧸ Ideal.span {c})[X]) f :
            (HasQuotient.Quotient R (B := Ideal R) (Ideal.span {c}))[X]))

Tactic:
rw [Set.preimage_diff, preimage_comap_zeroLocus, preimage_comap_zeroLocus,
          Set.image_singleton, Set.range_comp, AlgHom.toRingHom_eq_coe]

Premises used: Set.range_comp, Set.image_singleton, PrimeSpectrum.preimage_comap_zeroLocus, AlgHom.toRingHom_eq_coe, Set.preimage_diff