/-- If `S` is a finite `R`-algebra, then `S' = M⁻¹S` is a finite `R' = M⁻¹R`-algebra. -/
theorem localization_finite : RingHom.LocalizationPreserves @RingHom.Finite := by
  introv R hf
  -- Setting up the `algebra` and `is_scalar_tower` instances needed
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  letI := f'.toAlgebra
  haveI : IsScalarTower R R' S' := IsScalarTower.of_algebraMap_eq'
    (IsLocalization.map_comp M.le_comap_map).symm
  let fₐ : S →ₐ[R] S' := AlgHom.mk' (algebraMap S S') fun c x => RingHom.map_mul _ _ _
  -- We claim that if `S` is generated by `T` as an `R`-module,
  -- then `S'` is generated by `T` as an `R'`-module.
  obtain ⟨T, hT⟩ := hf
  use T.image (algebraMap S S')
  rw [eq_top_iff]
  rintro x -
  -- By the hypotheses, for each `x : S'`, we have `x = y / (f r)` for some `y : S` and `r : M`.
  -- Since `S` is generated by `T`, the image of `y` should fall in the span of the image of `T`.
  obtain ⟨y, ⟨_, ⟨r, hr, rfl⟩⟩, rfl⟩ := IsLocalization.mk'_surjective (M.map f) x
  rw [IsLocalization.mk'_eq_mul_mk'_one, mul_comm, Finset.coe_image]
  have hy : y ∈ Submodule.span R ↑T := by rw [hT]; trivial
  replace hy : algebraMap S S' y ∈ Submodule.map fₐ.toLinearMap (Submodule.span R (T : Set S)) :=
    Submodule.mem_map_of_mem hy
  rw [Submodule.map_span fₐ.toLinearMap T] at hy
  have H : Submodule.span R (algebraMap S S' '' T) ≤
      (Submodule.span R' (algebraMap S S' '' T)).restrictScalars R := by
    rw [Submodule.span_le]; exact Submodule.subset_span
  -- Now, since `y ∈ span T`, and `(f r)⁻¹ ∈ R'`, `x / (f r)` is in `span T` as well.
  convert (Submodule.span R' (algebraMap S S' '' T)).smul_mem
    (IsLocalization.mk' R' (1 : R) ⟨r, hr⟩) (H hy) using 1
  rw [Algebra.smul_def]
  

Proof state:
case h.e'_4
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
  AlgHom.mk' (algebraMap S S')
    (_ : ∀ (c : R) (x : S), (algebraMap S S') (f c * x) = (algebraMap S S') (f c) * (algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : (algebraMap S S') y ∈ Submodule.span R (⇑(AlgHom.toLinearMap fₐ) '' ↑T)
H :
  Submodule.span R (⇑(algebraMap S S') '' ↑T) ≤
    Submodule.restrictScalars R (Submodule.span R' (⇑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := f r, property := (_ : ∃ a ∈ ↑M, f a = f r) } * (algebraMap S S') y =
    (algebraMap R' S') (IsLocalization.mk' R' 1 { val := r, property := hr }) * (algebraMap S S') y

Next tactic:
erw [IsLocalization.map_mk' M.le_comap_map]