/-- `AlgHom`s from the top of a tower are equivalent to a pair of `AlgHom`s. -/
def algHomEquivSigma : (C →ₐ[A] D) ≃ Σf : B →ₐ[A] D, @AlgHom B C D _ _ _ _ f.toRingHom.toAlgebra
    where
  toFun f := ⟨f.restrictDomain B, f.extendScalars B⟩
  invFun fg :=
    let _ := fg.1.toRingHom.toAlgebra
    fg.2.restrictScalars A
  left_inv f := by
    dsimp only
    ext
    rfl
  right_inv := by
    rintro ⟨⟨⟨⟨⟨f, _⟩, _⟩, _⟩, _⟩, ⟨⟨⟨⟨g, _⟩, _⟩, _⟩, hg⟩⟩
    obtain rfl : f = fun x => g (algebraMap B C x) := by
      ext x
      exact (hg x).symm
    

Proof state:
case mk.mk.mk.mk.mk.mk.mk.mk.mk
R : Type u
S : Type v
A : Type w
B : Type u₁
C : Type u_1
D : Type u_2
inst✝⁸ : CommSemiring A
inst✝⁷ : CommSemiring C
inst✝⁶ : CommSemiring D
inst✝⁵ : Algebra A C
inst✝⁴ : Algebra A D
f : C →ₐ[A] D
inst✝³ : CommSemiring B
inst✝² : Algebra A B
inst✝¹ : Algebra B C
inst✝ : IsScalarTower A B C
g : C → D
map_one'✝¹ : g 1 = 1
map_mul'✝¹ :
  ∀ (x y : C),
    OneHom.toFun { toFun := g, map_one' := map_one'✝¹ } (x * y) =
      OneHom.toFun { toFun := g, map_one' := map_one'✝¹ } x * OneHom.toFun { toFun := g, map_one' := map_one'✝¹ } y
map_zero'✝¹ : OneHom.toFun (↑{ toOneHom := { toFun := g, map_one' := map_one'✝¹ }, map_mul' := map_mul'✝¹ }) 0 = 0
map_add'✝¹ :
  ∀ (x y : C),
    OneHom.toFun (↑{ toOneHom := { toFun := g, map_one' := map_one'✝¹ }, map_mul' := map_mul'✝¹ }) (x + y) =
      OneHom.toFun (↑{ toOneHom := { toFun := g, map_one' := map_one'✝¹ }, map_mul' := map_mul'✝¹ }) x +
        OneHom.toFun (↑{ toOneHom := { toFun := g, map_one' := map_one'✝¹ }, map_mul' := map_mul'✝¹ }) y
map_one'✝ : (fun x => g ((algebraMap B C) x)) 1 = 1
map_mul'✝ :
  ∀ (x y : B),
    OneHom.toFun { toFun := fun x => g ((algebraMap B C) x), map_one' := map_one'✝ } (x * y) =
      OneHom.toFun { toFun := fun x => g ((algebraMap B C) x), map_one' := map_one'✝ } x *
        OneHom.toFun { toFun := fun x => g ((algebraMap B C) x), map_one' := map_one'✝ } y
map_zero'✝ :
  OneHom.toFun
      (↑{ toOneHom := { toFun := fun x => g ((algebraMap B C) x), map_one' := map_one'✝ }, map_mul' := map_mul'✝ }) 0 =
    0
map_add'✝ :
  ∀ (x y : B),
    OneHom.toFun
        (↑{ toOneHom := { toFun := fun x => g ((algebraMap B C) x), map_one' := map_one'✝ }, map_mul' := map_mul'✝ })
        (x + y) =
      OneHom.toFun
          (↑{ toOneHom := { toFun := fun x => g ((algebraMap B C) x), map_one' := map_one'✝ }, map_mul' := map_mul'✝ })
          x +
        OneHom.toFun
          (↑{ toOneHom := { toFun := fun x => g ((algebraMap B C) x), map_one' := map_one'✝ }, map_mul' := map_mul'✝ })
          y
commutes'✝ :
  ∀ (r : A),
    OneHom.toFun
        (↑↑{
              toMonoidHom :=
                { toOneHom := { toFun := fun x => g ((algebraMap B C) x), map_one' := map_one'✝ },
                  map_mul' := map_mul'✝ },
              map_zero' := map_zero'✝, map_add' := map_add'✝ })
        ((algebraMap A B) r) =
      (algebraMap A D) r
hg :
  ∀ (r : B),
    OneHom.toFun
        (↑↑{ toMonoidHom := { toOneHom := { toFun := g, map_one' := map_one'✝¹ }, map_mul' := map_mul'✝¹ },
              map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ })
        ((algebraMap B C) r) =
      (algebraMap B D) r
⊢ (fun f => { fst := AlgHom.restrictDomain B f, snd := AlgHom.extendScalars B f })
      ((fun fg =>
          let x := RingHom.toAlgebra ↑fg.fst;
          AlgHom.restrictScalars A fg.snd)
        {
          fst :=
            {
              toRingHom :=
                {
                  toMonoidHom :=
                    { toOneHom := { toFun := fun x => g ((algebraMap B C) x), map_one' := map_one'✝ },
                      map_mul' := map_mul'✝ },
                  map_zero' := map_zero'✝, map_add' := map_add'✝ },
              commutes' := commutes'✝ },
          snd :=
            {
              toRingHom :=
                { toMonoidHom := { toOneHom := { toFun := g, map_one' := map_one'✝¹ }, map_mul' := map_mul'✝¹ },
                  map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ },
              commutes' := hg } }) =
    {
      fst :=
        {
          toRingHom :=
            {
              toMonoidHom :=
                { toOneHom := { toFun := fun x => g ((algebraMap B C) x), map_one' := map_one'✝ },
                  map_mul' := map_mul'✝ },
              map_zero' := map_zero'✝, map_add' := map_add'✝ },
          commutes' := commutes'✝ },
      snd :=
        {
          toRingHom :=
            { toMonoidHom := { toOneHom := { toFun := g, map_one' := map_one'✝¹ }, map_mul' := map_mul'✝¹ },
              map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ },
          commutes' := hg } }

Next tactic:
rfl